public class ArgumentParserBuilder extends Object
Modifier and Type | Method and Description |
---|---|
ArgumentParserBuilder |
addHelp(boolean flag)
If true,
-h/--help are available. |
ArgumentParser |
build() |
ArgumentParserBuilder |
cjkWidthHack(boolean flag)
Set
true to enable CJK width hack. |
ArgumentParserBuilder |
defaultFormatWidth(int defaultFormatWidth)
Set the default format width.
|
ArgumentParserBuilder |
fromFilePrefix(String fromFilePrefix)
The set of characters that prefix file path from which
additional arguments should be read.
|
ArgumentParserBuilder |
locale(Locale locale)
The locale to use for messages.
|
ArgumentParserBuilder |
noDestConversionForPositionalArgs(boolean flag)
Do not perform any conversion to produce "dest" value (See
Argument.getDest() ) from positional argument name. |
ArgumentParserBuilder |
prefixChars(String prefixChars)
The set of characters that prefix named arguments.
|
ArgumentParserBuilder |
singleMetavar(boolean flag)
If singleMetavar is
true , a metavar string in help message is
only shown after the last flag instead of each flag. |
ArgumentParserBuilder |
terminalWidthDetection(boolean flag)
Set
true to enable terminal width detection. |
public ArgumentParserBuilder addHelp(boolean flag)
If true, -h/--help
are available. If false, they are
not. Default value: true
.
flag
- true
or false
public ArgumentParserBuilder prefixChars(String prefixChars)
The set of characters that prefix named arguments. Default value:
"-"
.
prefixChars
- The named argument prefixes.public ArgumentParserBuilder fromFilePrefix(String fromFilePrefix)
The set of characters that prefix file path from which
additional arguments should be read. Specify null
to
disable reading arguments from file. Default value: null
.
fromFilePrefix
- The from file path prefixes.public ArgumentParserBuilder locale(Locale locale)
The locale to use for messages. Default value: Locale.getDefault()
.
locale
- The locale for messages.public ArgumentParserBuilder cjkWidthHack(boolean flag)
Set true
to enable CJK width hack.
The CJK width hack is treat Unicode characters having East Asian Width property Wide/Full/Ambiguous to have twice a width of ascii characters when formatting help message if locale is "ja", "zh" or "ko". This feature is enabled by default.
flag
- true
or false
public ArgumentParserBuilder defaultFormatWidth(int defaultFormatWidth)
Set the default format width. This width is used when terminal width
detection is disabled or when terminal width detection cannot detect the
actual number of columns. Default value:
ArgumentParsers.DEFAULT_FORMAT_WIDTH
.
defaultFormatWidth
- The default format width.public ArgumentParserBuilder terminalWidthDetection(boolean flag)
Set true
to enable terminal width detection.
If this feature is enabled, argparse4j will automatically detect the terminal width and use it to format help messages. This feature is enabled by default.
flag
- true
or false
public ArgumentParserBuilder singleMetavar(boolean flag)
If singleMetavar is true
, a metavar string in help message is
only shown after the last flag instead of each flag.
By default and false
is given to this method, a metavar is shown
after each flag:
-f FOO, --foo FOO
If true
is given to this method, a metavar string is shown only
once:
-f, --foo FOO
flag
- Switch to display a metavar only after the last flag.public ArgumentParserBuilder noDestConversionForPositionalArgs(boolean flag)
Do not perform any conversion to produce "dest" value (See
Argument.getDest()
) from positional argument name.
Prior 0.5.0, no conversion is made to produce "dest" value from positional argument name. Since 0.5.0, "dest" value is generated by replacing "-" with "_" in positional argument name. This is the same conversion rule for named arguments.
By default, this is set to false
(which means, conversion will be
done). Application is advised to update its implementation to cope with
this change. But if it is not feasible, call this method with
true
to turn off the conversion and retain the same behaviour
with pre-0.5.0 version.
flag
- Switch not to perform conversion to produce dest for positional
arguments. If true
is given, no conversion is made.public ArgumentParser build()
Copyright © 2012–2017. All rights reserved.