public class CmdLineParser
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
CmdLineParser.IllegalOptionValueException
Thrown when an illegal or missing value is given by the user for
an option that takes a value.
|
static class |
CmdLineParser.NotFlagException
Thrown when the parsed commandline contains multiple concatenated
short options, such as -abcd, where one or more requires a value.
|
static class |
CmdLineParser.Option
Representation of a command-line option
|
static class |
CmdLineParser.OptionException
Base class for exceptions that may be thrown when options are parsed
|
static class |
CmdLineParser.UnknownOptionException
Thrown when the parsed command-line contains an option that is not
recognised.
|
static class |
CmdLineParser.UnknownSuboptionException
Thrown when the parsed commandline contains multiple concatenated
short options, such as -abcd, where one is unknown.
|
Constructor and Description |
---|
CmdLineParser() |
Modifier and Type | Method and Description |
---|---|
CmdLineParser.Option |
addBooleanOption(char shortForm,
java.lang.String longForm)
Convenience method for adding a boolean option.
|
CmdLineParser.Option |
addBooleanOption(java.lang.String longForm)
Convenience method for adding a boolean option.
|
CmdLineParser.Option |
addDoubleOption(char shortForm,
java.lang.String longForm)
Convenience method for adding a double option.
|
CmdLineParser.Option |
addDoubleOption(java.lang.String longForm)
Convenience method for adding a double option.
|
CmdLineParser.Option |
addIntegerOption(char shortForm,
java.lang.String longForm)
Convenience method for adding an integer option.
|
CmdLineParser.Option |
addIntegerOption(java.lang.String longForm)
Convenience method for adding an integer option.
|
CmdLineParser.Option |
addLongOption(char shortForm,
java.lang.String longForm)
Convenience method for adding a long integer option.
|
CmdLineParser.Option |
addLongOption(java.lang.String longForm)
Convenience method for adding a long integer option.
|
CmdLineParser.Option |
addOption(CmdLineParser.Option opt)
Add the specified Option to the list of accepted options
|
CmdLineParser.Option |
addStringOption(char shortForm,
java.lang.String longForm)
Convenience method for adding a string option.
|
CmdLineParser.Option |
addStringOption(java.lang.String longForm)
Convenience method for adding a string option.
|
java.lang.Object |
getOptionValue(CmdLineParser.Option o)
Equivalent to
getOptionValue(o,
null) . |
java.lang.Object |
getOptionValue(CmdLineParser.Option o,
java.lang.Object def) |
java.util.Vector |
getOptionValues(CmdLineParser.Option option) |
java.lang.String[] |
getRemainingArgs() |
void |
parse(java.lang.String[] argv)
Extract the options and non-option arguments from the given
list of command-line arguments.
|
void |
parse(java.lang.String[] argv,
java.util.Locale locale)
Extract the options and non-option arguments from the given
list of command-line arguments.
|
public final CmdLineParser.Option addOption(CmdLineParser.Option opt)
public final CmdLineParser.Option addStringOption(char shortForm, java.lang.String longForm)
public final CmdLineParser.Option addStringOption(java.lang.String longForm)
public final CmdLineParser.Option addIntegerOption(char shortForm, java.lang.String longForm)
public final CmdLineParser.Option addIntegerOption(java.lang.String longForm)
public final CmdLineParser.Option addLongOption(char shortForm, java.lang.String longForm)
public final CmdLineParser.Option addLongOption(java.lang.String longForm)
public final CmdLineParser.Option addDoubleOption(char shortForm, java.lang.String longForm)
public final CmdLineParser.Option addDoubleOption(java.lang.String longForm)
public final CmdLineParser.Option addBooleanOption(char shortForm, java.lang.String longForm)
public final CmdLineParser.Option addBooleanOption(java.lang.String longForm)
public final java.lang.Object getOptionValue(CmdLineParser.Option o)
getOptionValue(o,
null)
.public final java.lang.Object getOptionValue(CmdLineParser.Option o, java.lang.Object def)
public final java.util.Vector getOptionValues(CmdLineParser.Option option)
public final java.lang.String[] getRemainingArgs()
public final void parse(java.lang.String[] argv) throws CmdLineParser.IllegalOptionValueException, CmdLineParser.UnknownOptionException
public final void parse(java.lang.String[] argv, java.util.Locale locale) throws CmdLineParser.IllegalOptionValueException, CmdLineParser.UnknownOptionException