Command line parser that parses arguments to the command line. Written as a replacement for Commons CLI because it doesn't support unknown arguments and requires all arguments to be declared up front. It also doesn't support command options with hyphens. This class gets around those problems.
Type | Name and description |
---|---|
void |
addOption(java.lang.String name, java.lang.String description) Adds a declared option |
protected DefaultCommandLine |
createCommandLine() |
static CommandLine |
getCurrentCommandLine() |
java.lang.String |
getOptionsHelpMessage() |
CommandLine |
parse(java.lang.String... args) Parses the given list of command line arguments. |
CommandLine |
parseString(java.lang.String string) Parses a string of all the command line options converting them into an array of arguments to pass to #parse(String..args) |
CommandLine |
parseString(java.lang.String commandName, java.lang.String args) Parses a string of all the command line options converting them into an array of arguments to pass to #parse(String..args) |
protected void |
processOption(DefaultCommandLine cl, java.lang.String arg) |
protected void |
processSystemArg(DefaultCommandLine cl, java.lang.String arg) |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Adds a declared option
name
- The name of the optiondescription
- The descriptionParses the given list of command line arguments. Arguments starting with -D become system properties, arguments starting with -- or - become either declared or undeclared options. All other arguments are put into a list of remaining arguments
args
- The argumentsParses a string of all the command line options converting them into an array of arguments to pass to #parse(String..args)
string
- The stringParses a string of all the command line options converting them into an array of arguments to pass to #parse(String..args)
commandName
- The command nameargs
- The string