|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.compomics.util.general.CommandLineParser
public class CommandLineParser
This class provides a generic interface for the parsing of
command-line arguments, options and flags.
Arguments are 'stand-alone' Strings, options are preceded
by '--' without spaces (like in general GNU practice) and
flags are indicated by '-' without spaces.
If there are options that in turn take arguments,
these can be specified via a specific constructor.
Constructor Summary | |
---|---|
CommandLineParser(String[] aCommandLine)
The constructor requires the caller to provide it with a command line arguments String[] that will be the basis of the parsing. |
|
CommandLineParser(String[] aCommandLine,
String[] aOptionArgs)
This constructor requests the command-line String[] as well as a String[] with a list of options which in turn take a parameter. |
Method Summary | |
---|---|
String[] |
getFlags()
This method will report on all flags that have been found, or return an empty String[] if none were present. |
String |
getOptionParameter(String aOption)
This method will report the option parameter for an option that can take a parameter itself. |
String[] |
getOptions()
This method will report on all options that have been found, or return an empty String[] if none were present. |
String[] |
getParameters()
This method will report on all parameters that have been found, or return an empty String[] if none were present. |
boolean |
hasArguments()
This method returns 'true' if any arguments are present, 'false' otherwise. |
boolean |
hasFlag(String aFlag)
This method test whether the specified flag was set on the commandline. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CommandLineParser(String[] aCommandLine)
aCommandLine
- String[] with the command-line arguments.public CommandLineParser(String[] aCommandLine, String[] aOptionArgs)
aCommandLine
- String[] with the command-line arguments.aOptionArgs
- String[] with the options that take
parameters themselves.Method Detail |
---|
public boolean hasArguments()
public String[] getFlags()
public String[] getOptions()
public String[] getParameters()
public String getOptionParameter(String aOption)
aOption
- String with the option for which the parameter is
to be retrieved.
public boolean hasFlag(String aFlag)
aFlag
- String with the flag to check. Comparison is case-sensitive!
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |