|
TUM CCSM Commons | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.tum.cs.commons.options.CommandLine
public class CommandLine
A class providing command line parsing and usage messages using GNU syntax.
The GNU syntax is implemented as follows. There are short (single character) and long (multi character) options, just as provided by the AOption annotation. Short options are introduced using a single minus (e.g. '-h') while long options are introduced using a double minus (e.g. '--help'). The parameter for an option is either the next argument, or--in case of long options--possibly separated by an equals sign (e.g. '--file=test.txt'). Short options may be chained (e.g. '-xvf abc' instead of '-x -v -f abc'). For chained short options, only the last option may take a parameter.
Constructor Summary | |
---|---|
CommandLine(OptionRegistry registry)
Constructor. |
Method Summary | |
---|---|
java.lang.String[] |
parse(CommandLineTokenStream ts)
Parses the command line parameters implicitly given by the token stream and applies the options found. |
java.lang.String[] |
parse(java.lang.String[] args)
Parses the given command line parameters and applies the options found. |
void |
printUsage(java.io.PrintWriter pw)
Print the list of all supported options using reasonable default values for widths. |
void |
printUsage(java.io.PrintWriter pw,
int firstCol,
int width)
Print the list of all supported options. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CommandLine(OptionRegistry registry)
registry
- Registry containing the options to be used by this instance.Method Detail |
---|
public java.lang.String[] parse(java.lang.String[] args) throws OptionException
OptionException
is thrown.
args
- the command line arguments to be parsed.
OptionException
- in case of syntax errors or invalid parameters.public java.lang.String[] parse(CommandLineTokenStream ts) throws OptionException
ts
- Token stream containing the arguments.
OptionException
- in case of syntax errors or invalid parameters.public void printUsage(java.io.PrintWriter pw)
pw
- the writer used for output.public void printUsage(java.io.PrintWriter pw, int firstCol, int width)
pw
- the writer to print to.firstCol
- the width of the first column containing the option name
(without the trailing space).width
- the maximal width of a line (aka terminal width).
|
TUM CCSM Commons | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |