Command line argument processing based on a trigger model.
An action is called whenever an argument is encountered. Example:
public static void main (String[] args)
{
CommandLine cl = new CommandLine() ;
cl.add(false, "verbose")
.add(true, "--file") ;
cl.process(args) ;
for ( Iterator iter = cl.args() ; iter.hasNext() ; )
...
}
A gloabl hook is provided to inspect arguments just before the
action. Tracing is enabled by setting this to a suitable function
such as that provided by trace():
cl.setHook(cl.trace()) ;
Neutral as to whether options have - or --
Does not allow multiple single letter options to be concatenated.
Add an argument to those to be accepted on the command line.
Parameters: argName - Name Parameters: hasValue - True if the command takes a (string) value The CommandLine processor object
Add an argument to those to be accepted on the command line.
Argument order reflects ArgDecl.
Parameters: hasValue - True if the command takes a (string) value Parameters: argName - Name The CommandLine processor object
Answer true if this argument terminates argument processing for the rest
of the command line. Default is to stop just before the first arg that
does not start with "-", or is "-" or "--".
Get the argument associated with the argument declaration.
Actually returns the LAST one seen
Parameters: argDecl - Argument declaration to find Last argument that matched.
Get the argument associated with the arguement name.
Actually returns the LAST one seen
Parameters: argDecl - Argument declaration to find Last argument that matched.
Process a set of command line arguments.
Parameters: argv - The words of the command line. throws: IllegalArgumentException - Throw when something is wrong (no value found, action fails).