-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Intentionally made private to avoid to get instantiated in application code. -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
Deprecated.This is not thread safe.static int
Deprecated.This is not thread safe.static boolean
Deprecated.This is not thread safe.static boolean
Deprecated.This is not thread safe.static boolean
Deprecated.This is not thread safe.static ArgumentParser
newArgumentParser
(String prog) Deprecated.This is not thread safe.static ArgumentParser
newArgumentParser
(String prog, boolean addHelp) Deprecated.This is not thread safe.static ArgumentParser
newArgumentParser
(String prog, boolean addHelp, String prefixChars) Deprecated.This is not thread safe.static ArgumentParser
newArgumentParser
(String prog, boolean addHelp, String prefixChars, String fromFilePrefix) Deprecated.This is not thread safe.static ArgumentParserBuilder
CreatesArgumentParserBuilder
with given program name.static ArgumentParserBuilder
newFor
(String prog, DefaultSettings defaultSettings) CreatesArgumentParserBuilder
with given program name and default settings.static void
setCJKWidthHack
(boolean flag) Deprecated.This is not thread safe.static void
setNoDestConversionForPositionalArgs
(boolean flag) Deprecated.This is not thread safe.static void
setSingleMetavar
(boolean singleMetavar) Deprecated.This is not thread safe.static void
setTerminalWidthDetection
(boolean flag) Deprecated.This is not thread safe.
-
Field Details
-
DEFAULT_PREFIX_CHARS
Default prefix characters.- See Also:
-
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
ArgumentParserBuilder
with given program name.- Parameters:
prog
- The program name- Returns:
- ArgumentParserBuilder object
- Since:
- 0.8.0
-
newFor
Creates
ArgumentParserBuilder
with 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
ArgumentParser
with 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
ArgumentParser
with given program name and addHelp.This is equivalent with
ArgumentParser(prog, addHelp, "-", null)
.- Parameters:
prog
- The program nameaddHelp
- If true,-h/--help
are 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
ArgumentParser
with given program name, addHelp and prefixChars.This is equivalent with
ArgumentParser(prog, addHelp, prefixChars, null)
.- Parameters:
prog
- The program nameaddHelp
- If true,-h/--help
are 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
ArgumentParser
with given program name, addHelp and prefixChars.- Parameters:
prog
- The program nameaddHelp
- If true,-h/--help
are 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. Specifynull
to disable reading arguments from file.- Returns:
- ArgumentParser object.
-
setCJKWidthHack
Deprecated.This is not thread safe. UsenewFor(String)
instead.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.
- Parameters:
flag
-true
orfalse
-
getCjkWidthHack
Deprecated.This is not thread safe. UsenewFor(String)
instead.Returns true iff CJK width hack is enabled.- Returns:
true
orfalse
-
setTerminalWidthDetection
Deprecated.This is not thread safe. UsenewFor(String)
instead.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.
- Parameters:
flag
-true
orfalse
-
getTerminalWidthDetection
Deprecated.This is not thread safe. UsenewFor(String)
instead.Returns true iff terminal width detection is enabled.- Returns:
true
orfalse
-
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_WIDTH
is 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
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
- 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:
true
orfalse
-
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 withtrue
to 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. Iftrue
is given, no conversion is made.
-
getNoDestConversionForPositionalArgs
Deprecated.This is not thread safe. UsenewFor(String)
instead.Returnstrue
iff no destination value conversion for positional arguments is enabled.- Returns:
true
orfalse
-