|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--support143.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.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 |
consumeArgument(java.lang.String a)
Consumes (and processes) a single argument. |
protected boolean |
consumeFlaggedArgument(java.lang.String f)
Consumes a flagged argument so that its presence can later be queried. |
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()
Shows a help message to the console. |
void |
help(java.lang.String msg)
Shows 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 void |
setHelp(java.lang.String cmd,
java.lang.String help)
Associates a help message with a command. |
protected java.lang.String |
shiftCommandLine()
Shifts left the command line, dropping the first argument into oblivion. |
protected void |
showHelp()
Shows help messages. |
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.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 |
protected void setHelp(java.lang.String cmd, java.lang.String help)
cmd
- commandhelp
- help messagepublic void expectUnflaggedArguments(java.lang.String kind)
kind
- generic printable name for argspublic 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, false
otherwise.protected boolean consumeUnflaggedArgument(java.lang.String u)
u
- the unflagged argument.
true
if we expected unflagged arguments. else false
protected boolean consumeArgument(java.lang.String a)
a
- argument
true
if argument was valid, false
otherwise.public boolean parseCommandLine()
true
if args are consistent with expectation.
else false
public 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()
protected void showHelp()
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 |