net.dpml.cli.commandline
Class Parser
java.lang.Objectnet.dpml.cli.commandline.Parser
A class that implements the
Parser interface can parse a
String array according to the
Groupspecified and return a
CommandLine.
CommandLine | parse(String[] arguments)- Parse the arguments according to the specified options and properties.
|
CommandLine | parseAndHelp(String[] arguments)- Parse the arguments according to the specified options and properties and
displays the usage screen if the CommandLine is not valid or the help
option was specified.
|
void | setGroup(Group group)- Sets the Group of options to parse against
|
void | setHelpFormatter(HelpFormatter helpFormatter)- Sets the HelpFormatter to use with the simplified parsing.
|
void | setHelpOption(Option helpOption)- Sets the help option to use with the simplified parsing.
|
void | setHelpTrigger(String helpTrigger)- Sets the help option to use with the simplified parsing.
|
parse
public CommandLine parse(String[] arguments)
throws OptionException Parse the arguments according to the specified options and properties.
arguments - the command line arguments
- the list of atomic option and value tokens
OptionException - if there are any problems encountered while parsing the
command line tokens.
parseAndHelp
public CommandLine parseAndHelp(String[] arguments)
throws IOException Parse the arguments according to the specified options and properties and
displays the usage screen if the CommandLine is not valid or the help
option was specified.
arguments - the command line arguments
- a valid CommandLine or null if the parse was unsuccessful
setGroup
public void setGroup(Group group)
Sets the Group of options to parse against
group - the group of options to parse against
setHelpFormatter
public void setHelpFormatter(HelpFormatter helpFormatter)
Sets the HelpFormatter to use with the simplified parsing.
helpFormatter - the HelpFormatter to use with the simplified parsing
setHelpOption
public void setHelpOption(Option helpOption)
Sets the help option to use with the simplified parsing. For example
--help, -h and -? are often used.
helpOption - the help Option
setHelpTrigger
public void setHelpTrigger(String helpTrigger)
Sets the help option to use with the simplified parsing. For example
--help, -h and -? are often used.
helpTrigger - the trigger of the help Option