net.dpml.cli.commandline

Class Parser

public class Parser extends Object

A class that implements the Parser interface can parse a String array according to the Groupspecified and return a CommandLine.

Version: @PROJECT-VERSION@

Author: @PUBLISHER-NAME@

Method Summary
CommandLineparse(String[] arguments)
Parse the arguments according to the specified options and properties.
CommandLineparseAndHelp(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.
voidsetGroup(Group group)
Sets the Group of options to parse against
voidsetHelpFormatter(HelpFormatter helpFormatter)
Sets the HelpFormatter to use with the simplified parsing.
voidsetHelpOption(Option helpOption)
Sets the help option to use with the simplified parsing.
voidsetHelpTrigger(String helpTrigger)
Sets the help option to use with the simplified parsing.

Method Detail

parse

public CommandLine parse(String[] arguments)
Parse the arguments according to the specified options and properties.

Parameters: arguments the command line arguments

Returns: the list of atomic option and value tokens

Throws: OptionException if there are any problems encountered while parsing the command line tokens.

parseAndHelp

public 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.

Parameters: arguments the command line arguments

Returns: a valid CommandLine or null if the parse was unsuccessful

Throws: IOException if an error occurs while formatting help

setGroup

public void setGroup(Group group)
Sets the Group of options to parse against

Parameters: group the group of options to parse against

setHelpFormatter

public void setHelpFormatter(HelpFormatter helpFormatter)
Sets the HelpFormatter to use with the simplified parsing.

Parameters: helpFormatter the HelpFormatter to use with the simplified parsing

See Also: (String[])

setHelpOption

public void setHelpOption(Option helpOption)
Sets the help option to use with the simplified parsing. For example --help, -h and -? are often used.

Parameters: helpOption the help Option

See Also: (String[])

setHelpTrigger

public void setHelpTrigger(String helpTrigger)
Sets the help option to use with the simplified parsing. For example --help, -h and -? are often used.

Parameters: helpTrigger the trigger of the help Option

See Also: (String[])