public final class ArgumentParsers extends Object
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_FORMAT_WIDTH
Default format width of text output.
|
static String |
DEFAULT_PREFIX_CHARS
Default prefix characters.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
getCjkWidthHack()
Returns true iff CJK width hack is enabled.
|
static int |
getFormatWidth()
Returns the width of formatted text.
|
static boolean |
getTerminalWidthDetection()
Returns true iff terminal width detection is enabled.
|
static boolean |
isSingleMetavar()
Returns true iff a metavar is shown only after the last flag.
|
static ArgumentParser |
newArgumentParser(String prog)
Creates
ArgumentParser with given program name. |
static ArgumentParser |
newArgumentParser(String prog,
boolean addHelp)
Creates
ArgumentParser with given program name and addHelp. |
static ArgumentParser |
newArgumentParser(String prog,
boolean addHelp,
String prefixChars)
Creates
ArgumentParser with given program name, addHelp and
prefixChars. |
static ArgumentParser |
newArgumentParser(String prog,
boolean addHelp,
String prefixChars,
String fromFilePrefix)
Creates
ArgumentParser with given program name, addHelp and
prefixChars. |
static void |
setCJKWidthHack(boolean flag)
Set
true to enable CJK width hack. |
static void |
setSingleMetavar(boolean singleMetavar)
If singleMetavar is
true , a metavar string in help message is
only shown after the last flag instead of each flag. |
static void |
setTerminalWidthDetection(boolean flag)
Set
true to enable terminal width detection. |
public static final String DEFAULT_PREFIX_CHARS
public static final int DEFAULT_FORMAT_WIDTH
public static ArgumentParser newArgumentParser(String prog)
Creates ArgumentParser
with given program name.
This is equivalent with newArgumentParser(prog, true, "-", null)
.
prog
- The program namepublic static ArgumentParser newArgumentParser(String prog, boolean addHelp)
Creates ArgumentParser
with given program name and addHelp.
This is equivalent with ArgumentParser(prog, addHelp, "-", null)
.
prog
- The program nameaddHelp
- If true, -h/--help
are available. If false, they are
not.public static ArgumentParser newArgumentParser(String prog, boolean addHelp, String prefixChars)
Creates ArgumentParser
with given program name, addHelp and
prefixChars.
This is equivalent with
ArgumentParser(prog, addHelp, prefixChars, null)
.
prog
- The program nameaddHelp
- If true, -h/--help
are available. If false, they are
not.prefixChars
- The set of characters that prefix optional arguments.public static ArgumentParser newArgumentParser(String prog, boolean addHelp, String prefixChars, String fromFilePrefix)
Creates ArgumentParser
with given program name, addHelp and
prefixChars.
prog
- The program nameaddHelp
- If true, -h/--help
are available. If false, they are
not.prefixChars
- The set of characters that prefix optional arguments.fromFilePrefix
- The set of characters that prefix file path from which
additional arguments should be read. Specify null
to
disable reading arguments from file.public static void setCJKWidthHack(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 static boolean getCjkWidthHack()
true
or false
public static void setTerminalWidthDetection(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.
flag
- true
or false
public static boolean getTerminalWidthDetection()
true
or false
public static int getFormatWidth()
DEFAULT_FORMAT_WIDTH
is returned.public static void setSingleMetavar(boolean singleMetavar)
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
singleMetavar
- Switch to display a metavar only after the last flag.public static boolean isSingleMetavar()
true
or false
Copyright © 2012–2015. All rights reserved.