|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--Args
Args class for managing command line arguments. A command line argument can be a flag, which is either present or not, or "anything else".
| Field Summary | |
protected java.util.HashMap |
flags
|
protected java.lang.String |
helpMessages
|
protected java.util.ArrayList |
unflaggedArgs
|
| Constructor Summary | |
Args(java.lang.String mainName,
java.lang.String[] commandLine)
Sole Constructor. |
|
| Method Summary | |
void |
addCommand(java.lang.String arg,
java.lang.String helpMsg)
Creates a given command and associates it with the help message. |
protected boolean |
consumeFlaggedArgument(java.lang.String f)
Consumes a flag. |
protected boolean |
consumeUnflaggedArgument(java.lang.String u)
Consumes an unflagged argument. |
void |
expectUnflaggedArguments(java.lang.String kind)
Allows for arguments without "-"'s |
java.lang.String[] |
getNonFlaggedArguments()
Fetches all non flagged arguments. |
int |
getRemainingCommandLineArguments()
Computes how many command line arguments remain for parsing. |
void |
help()
Displays a help message to the console. |
void |
help(java.lang.String msg)
Displays a prefixed help message to the console. |
boolean |
isFlagPresent(java.lang.String f)
Checks if a given flag is present in the command line. |
boolean |
parseCommandLine()
Parses any unparsed command line arguments. |
protected java.lang.String |
shiftCommandLine()
Left shifts the given command line, dropping the first argument into oblivion. |
void |
showUsage()
Displays invocation template. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected java.util.HashMap flags
protected java.lang.String helpMessages
protected java.util.ArrayList unflaggedArgs
| Constructor Detail |
public Args(java.lang.String mainName,
java.lang.String[] commandLine)
mainName - name of driver modulecommandLine - that should be parsed!| Method Detail |
public void expectUnflaggedArguments(java.lang.String kind)
kind - generic printable name for args
public void addCommand(java.lang.String arg,
java.lang.String helpMsg)
arg - flagged argument (eg, "-t"). Includes the dash (-)helpMsg - any associated help textprotected java.lang.String shiftCommandLine()
null if command line empty.public int getRemainingCommandLineArguments()
protected boolean consumeFlaggedArgument(java.lang.String f)
f - flag
true if flag was expected, falseotherwise.protected boolean consumeUnflaggedArgument(java.lang.String u)
u - the unflagged argument.
trueif we expected unflagged arguments. else falsepublic boolean parseCommandLine()
trueif args are consistent with expectation.
else falsepublic boolean isFlagPresent(java.lang.String f)
f - flag to check. Should include the "-"
true if arg present. else false.public java.lang.String[] getNonFlaggedArguments()
public void showUsage()
public void help(java.lang.String msg)
msg - any prefixing message which should be included.public void help()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||