- java.lang.Object
-
- net.sourceforge.argparse4j.ArgumentParsers
-
public final class ArgumentParsers extends java.lang.ObjectFactory class to create new ArgumentParser.
-
-
Field Summary
Fields Modifier and Type Field Description private static booleancjkWidthHack_(package private) static java.util.List<java.lang.String>cjkWidthLangs_private static java.lang.String[]cjkWidthLangsSrc_static intDEFAULT_FORMAT_WIDTHDefault format width of text output.static java.lang.StringDEFAULT_PREFIX_CHARSDefault prefix characters.private static booleannoDestConversionForPositionalArgs_private static booleansingleMetavar_private static booleanterminalWidthDetection_
-
Constructor Summary
Constructors Modifier Constructor Description privateArgumentParsers()Intentionally made private to avoid to get instantiated in application code.
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static booleangetCjkWidthHack()Deprecated.This is not thread safe.static intgetFormatWidth()Deprecated.This is not thread safe.static booleangetNoDestConversionForPositionalArgs()Deprecated.This is not thread safe.static booleangetTerminalWidthDetection()Deprecated.This is not thread safe.static booleanisSingleMetavar()Deprecated.This is not thread safe.static ArgumentParsernewArgumentParser(java.lang.String prog)Deprecated.This is not thread safe.static ArgumentParsernewArgumentParser(java.lang.String prog, boolean addHelp)Deprecated.This is not thread safe.static ArgumentParsernewArgumentParser(java.lang.String prog, boolean addHelp, java.lang.String prefixChars)Deprecated.This is not thread safe.static ArgumentParsernewArgumentParser(java.lang.String prog, boolean addHelp, java.lang.String prefixChars, java.lang.String fromFilePrefix)Deprecated.This is not thread safe.static ArgumentParserBuildernewFor(java.lang.String prog)CreatesArgumentParserBuilderwith given program name.static ArgumentParserBuildernewFor(java.lang.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 Detail
-
DEFAULT_PREFIX_CHARS
public static final java.lang.String DEFAULT_PREFIX_CHARS
Default prefix characters.- See Also:
- Constant Field Values
-
cjkWidthLangsSrc_
private static final java.lang.String[] cjkWidthLangsSrc_
-
cjkWidthLangs_
static java.util.List<java.lang.String> cjkWidthLangs_
-
cjkWidthHack_
private static boolean cjkWidthHack_
-
terminalWidthDetection_
private static boolean terminalWidthDetection_
-
DEFAULT_FORMAT_WIDTH
public static final int DEFAULT_FORMAT_WIDTH
Default format width of text output.- See Also:
- Constant Field Values
-
singleMetavar_
private static boolean singleMetavar_
-
noDestConversionForPositionalArgs_
private static boolean noDestConversionForPositionalArgs_
-
-
Method Detail
-
newFor
public static ArgumentParserBuilder newFor(java.lang.String prog)
Creates
ArgumentParserBuilderwith given program name.- Parameters:
prog- The program name- Returns:
- ArgumentParserBuilder object
- Since:
- 0.8.0
-
newFor
public static ArgumentParserBuilder newFor(java.lang.String prog, DefaultSettings defaultSettings)
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 public static ArgumentParser newArgumentParser(java.lang.String prog)
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 public static ArgumentParser newArgumentParser(java.lang.String prog, boolean addHelp)
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(java.lang.String prog, boolean addHelp, java.lang.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(java.lang.String prog, boolean addHelp, java.lang.String prefixChars, java.lang.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 public static void setCJKWidthHack(boolean flag)
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 public static boolean getCjkWidthHack()
Deprecated.This is not thread safe. UsenewFor(String)instead.Returns true iff CJK width hack is enabled.- Returns:
trueorfalse
-
setTerminalWidthDetection
@Deprecated public static void setTerminalWidthDetection(boolean flag)
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 public static boolean getTerminalWidthDetection()
Deprecated.This is not thread safe. UsenewFor(String)instead.Returns true iff terminal width detection is enabled.- Returns:
trueorfalse
-
getFormatWidth
@Deprecated public static int 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 public static void setSingleMetavar(boolean singleMetavar)
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 public static boolean 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 public static void setNoDestConversionForPositionalArgs(boolean flag)
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 public static boolean getNoDestConversionForPositionalArgs()
Deprecated.This is not thread safe. UsenewFor(String)instead.Returnstrueiff no destination value conversion for positional arguments is enabled.- Returns:
trueorfalse
-
-