Class ArgumentParsers
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateIntentionally made private to avoid to get instantiated in application code. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanDeprecated.This is not thread safe.static intDeprecated.This is not thread safe.static booleanDeprecated.This is not thread safe.static booleanDeprecated.This is not thread safe.static booleanDeprecated.This is not thread safe.static ArgumentParsernewArgumentParser(String prog) Deprecated.This is not thread safe.static ArgumentParsernewArgumentParser(String prog, boolean addHelp) Deprecated.This is not thread safe.static ArgumentParsernewArgumentParser(String prog, boolean addHelp, String prefixChars) Deprecated.This is not thread safe.static ArgumentParsernewArgumentParser(String prog, boolean addHelp, String prefixChars, String fromFilePrefix) Deprecated.This is not thread safe.static ArgumentParserBuilderCreatesArgumentParserBuilderwith given program name.static ArgumentParserBuildernewFor(String prog, DefaultSettings defaultSettings) CreatesArgumentParserBuilderwith given program name and default settings.static voidsetCJKWidthHack(boolean flag) Deprecated.This is not thread safe.static voidsetNoDestConversionForPositionalArgs(boolean flag) Deprecated.This is not thread safe.static voidsetSingleMetavar(boolean singleMetavar) Deprecated.This is not thread safe.static voidsetTerminalWidthDetection(boolean flag) Deprecated.This is not thread safe.
-
Field Details
-
DEFAULT_PREFIX_CHARS
-
cjkWidthLangsSrc_
-
cjkWidthLangs_
-
cjkWidthHack_
private static boolean cjkWidthHack_ -
terminalWidthDetection_
private static boolean terminalWidthDetection_ -
DEFAULT_FORMAT_WIDTH
public static final int DEFAULT_FORMAT_WIDTHDefault format width of text output.- See Also:
-
singleMetavar_
private static boolean singleMetavar_ -
noDestConversionForPositionalArgs_
private static boolean noDestConversionForPositionalArgs_
-
-
Constructor Details
-
ArgumentParsers
private ArgumentParsers()Intentionally made private to avoid to get instantiated in application code.
-
-
Method Details
-
newFor
Creates
ArgumentParserBuilderwith given program name.- Parameters:
prog- The program name- Returns:
- ArgumentParserBuilder object
- Since:
- 0.8.0
-
newFor
Creates
ArgumentParserBuilderwith given program name and default settings.- Parameters:
prog- The program namedefaultSettings- The default settings to use.- Returns:
- ArgumentParserBuilder object
- Since:
- 0.9.0
-
newArgumentParser
Deprecated.This is not thread safe. UsenewFor(String)instead.Creates
ArgumentParserwith given program name.This is equivalent with
newArgumentParser(prog, true, "-", null).- Parameters:
prog- The program name- Returns:
- ArgumentParser object
-
newArgumentParser
Deprecated.This is not thread safe. UsenewFor(String)instead.Creates
ArgumentParserwith given program name and addHelp.This is equivalent with
ArgumentParser(prog, addHelp, "-", null).- Parameters:
prog- The program nameaddHelp- If true,-h/--helpare available. If false, they are not.- Returns:
- ArgumentParser object
-
newArgumentParser
@Deprecated public static ArgumentParser newArgumentParser(String prog, boolean addHelp, String prefixChars) Deprecated.This is not thread safe. UsenewFor(String)instead.Creates
ArgumentParserwith given program name, addHelp and prefixChars.This is equivalent with
ArgumentParser(prog, addHelp, prefixChars, null).- Parameters:
prog- The program nameaddHelp- If true,-h/--helpare available. If false, they are not.prefixChars- The set of characters that prefix named arguments.- Returns:
- ArgumentParser object.
-
newArgumentParser
@Deprecated public static ArgumentParser newArgumentParser(String prog, boolean addHelp, String prefixChars, String fromFilePrefix) Deprecated.This is not thread safe. UsenewFor(String)instead.Creates
ArgumentParserwith given program name, addHelp and prefixChars.- Parameters:
prog- The program nameaddHelp- If true,-h/--helpare available. If false, they are not.prefixChars- The set of characters that prefix named arguments.fromFilePrefix- The set of characters that prefix file path from which additional arguments should be read. Specifynullto disable reading arguments from file.- Returns:
- ArgumentParser object.
-
setCJKWidthHack
Deprecated.This is not thread safe. UsenewFor(String)instead.Set
trueto 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.
- Parameters:
flag-trueorfalse
-
getCjkWidthHack
Deprecated.This is not thread safe. UsenewFor(String)instead.Returns true iff CJK width hack is enabled.- Returns:
trueorfalse
-
setTerminalWidthDetection
Deprecated.This is not thread safe. UsenewFor(String)instead.Set
trueto enable terminal width detection.If this feature is enabled, argparse4j will automatically detect the terminal width and use it to format help messages.
- Parameters:
flag-trueorfalse
-
getTerminalWidthDetection
Deprecated.This is not thread safe. UsenewFor(String)instead.Returns true iff terminal width detection is enabled.- Returns:
trueorfalse
-
getFormatWidth
Deprecated.This is not thread safe. UsenewFor(String)instead.Returns the width of formatted text. If the terminal width detection is enabled, this method will detect the terminal width automatically and calculate the width based on it. If it is not enabled or auto-detection was failed, theDEFAULT_FORMAT_WIDTHis returned.- Returns:
- the width of formatted text
-
setSingleMetavar
Deprecated.This is not thread safe. UsenewFor(String)instead.If singleMetavar is
true, a metavar string in help message is only shown after the last flag instead of each flag.By default and
falseis given to this method, a metavar is shown after each flag:-f FOO, --foo FOO
If
trueis given to this method, a metavar string is shown only once:-f, --foo FOO
- Parameters:
singleMetavar- Switch to display a metavar only after the last flag.
-
isSingleMetavar
Deprecated.This is not thread safe. UsenewFor(String)instead.Returns true iff a metavar is shown only after the last flag.- Returns:
trueorfalse
-
setNoDestConversionForPositionalArgs
Deprecated.This is not thread safe. UsenewFor(String)instead.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 withtrueto turn off the conversion and retain the same behaviour with pre-0.5.0 version.- Parameters:
flag- Switch not to perform conversion to produce dest for positional arguments. Iftrueis given, no conversion is made.
-
getNoDestConversionForPositionalArgs
Deprecated.This is not thread safe. UsenewFor(String)instead.Returnstrueiff no destination value conversion for positional arguments is enabled.- Returns:
trueorfalse
-