net.dpml.cli.commandline

Class Parser


public class Parser
extends java.lang.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

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.

Method Details

parse

public CommandLine parse(String[] arguments)
            throws OptionException
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)
            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.
Parameters:
arguments - the command line arguments
Returns:
a valid CommandLine or null if the parse was unsuccessful

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

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

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