dsto.dfc.commandline
Class CmdLineParser

java.lang.Object
  extended by dsto.dfc.commandline.CmdLineParser

public class CmdLineParser
extends Object

Vaguely GNU-compatible command-line options parser. Has short (-v) and long-form (--verbose) option support, and also allows options with associated values (-d 2, --debug 2, --debug=2).


Constructor Summary
CmdLineParser()
           
 
Method Summary
 void addOption(Option opt)
          Add an option as one of the possible legal options to use.
 Option[] getOptions()
          Get an array of all the possible options.
 String[] getRemainingArgs()
          Return the arguments that do not correspond to a particular option.
 void parse(String[] argv)
          This is the meat of the command line parser.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CmdLineParser

public CmdLineParser()
Method Detail

addOption

public final void addOption(Option opt)
Add an option as one of the possible legal options to use. This adds the longForm and shortForm version of the option.

Parameters:
opt - The option to be added as a legal Option

getOptions

public final Option[] getOptions()
Get an array of all the possible options.


getRemainingArgs

public final String[] getRemainingArgs()
Return the arguments that do not correspond to a particular option.


parse

public void parse(String[] argv)
           throws IllegalOptionValueException,
                  UnknownOptionException
This is the meat of the command line parser. This does all the parsing of the command line arguements and sets the right values.

Parameters:
argv - The array of strings that you want parsed.
Throws:
IllegalOptionValueException
UnknownOptionException


Copyright © 2008 Commonwealth of Australia