|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.cmu.minorthird.util.BasicCommandLineProcessor
public abstract class BasicCommandLineProcessor
A lightweight command-line processing tool.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface edu.cmu.minorthird.util.CommandLineProcessor |
---|
CommandLineProcessor.Configurable |
Constructor Summary | |
---|---|
BasicCommandLineProcessor()
|
Method Summary | |
---|---|
void |
config(java.lang.String fileName)
Implements the -config option. |
static void |
config(java.lang.String fileName,
CommandLineProcessor clp)
Implements the -config option for the given clp. |
int |
consumeArguments(java.lang.String[] args,
int startPos)
Try to consume a the command-line argument at position i. |
java.lang.String |
getExtensionFor(java.lang.String format)
Recomended extension for the format with the given name. |
java.lang.String[] |
getFormatNames()
List of formats in which the object can be saved. |
void |
help()
Override this to make --help do something other than call usage |
static void |
main(java.lang.String[] args)
Test and/or example code. |
void |
processArguments(java.lang.String[] args)
Loop thru the command-line arguments. |
protected java.util.List |
propertyList()
A list of arguments from the command line, in order. |
protected java.lang.String |
propertyValue(java.lang.String property)
The value assigned to a property from the command line. |
java.lang.Object |
restore(java.io.File file)
Restore the object from a file. |
void |
saveAs(java.io.File file,
java.lang.String format)
Save this object to the given file, in the given format. |
boolean |
shouldTerminate()
Specifies whether the commandline processing should terminate. |
protected CommandLineProcessor |
tryToGetCLP(java.lang.Object o)
|
void |
usage()
Override this to print a meaningful usage error. |
void |
usage(java.lang.String errorMessage)
Prints errorMessage and then calls usage(). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BasicCommandLineProcessor()
Method Detail |
---|
public final void processArguments(java.lang.String[] args)
CommandLineProcessor
If function like -foo happens to return a non-null
CommandLineProcessor, that processor is invoked on the
arguments immediately after foo. This allows one
CommandLineProcessor to pass command-line options to a second
one. For instance, if x and y are CommandLineProcessors, x has
an method colorOpts() that returns y, and y has methods
background(String s) and foreground(String t) then the command
line sequence -colorOpts -background blue -foreground
red
would call the expected methods of y.
The optional "-config FILE" should cause a Properties object to be loaded from FILE, and the property/value pairs in the Properties object to be treated as if they were option/argument pairs. The order of lines in the property file may not be preserved, however, and duplicated keys will be ignored.
For instance, calling -config FILE for a FILE containing
would be the same as the command options
baz=
foo=bar
-foo bar -baz
or possibly -baz -foo bar
processArguments
in interface CommandLineProcessor
public boolean shouldTerminate()
CommandLineProcessor
shouldTerminate
in interface CommandLineProcessor
public final int consumeArguments(java.lang.String[] args, int startPos)
CommandLineProcessor
consumeArguments
in interface CommandLineProcessor
public void config(java.lang.String fileName)
public static void config(java.lang.String fileName, CommandLineProcessor clp)
public void usage(java.lang.String errorMessage)
CommandLineProcessor
usage
in interface CommandLineProcessor
public void usage()
usage
in interface CommandLineProcessor
public void help()
protected java.util.List propertyList()
protected java.lang.String propertyValue(java.lang.String property)
public java.lang.String[] getFormatNames()
Saveable
getFormatNames
in interface Saveable
public java.lang.String getExtensionFor(java.lang.String format)
Saveable
getExtensionFor
in interface Saveable
public void saveAs(java.io.File file, java.lang.String format) throws java.io.IOException
Saveable
saveAs
in interface Saveable
java.io.IOException
public java.lang.Object restore(java.io.File file) throws java.io.IOException
Saveable
restore
in interface Saveable
java.io.IOException
public static void main(java.lang.String[] args)
protected CommandLineProcessor tryToGetCLP(java.lang.Object o)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |