|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--com.charliedog.argv.ArgumentParser
A parser for processing command line arguments. It is typically used as such:
// Initialize arguments that may appear in the command line. By convention,
// '-help' simply prints the command line usage and exits.
StringArgument destination = new StringArgument( "-dest", "localhost", "Destination for request tests" );
BooleanArgument help = new BooleanArgument( "-help", "Describe command line args" );
// Initialize and invoke the parser. Note that arguments not consumed during
// the parse are returned in case they may be subject to additional processing,
// etc. Variable 'args' is assumed to contain the String array passed to main().
ArgumentParser parser = new ArgumentParser();
parser.addArgument( destination );
parser.addArgument( skipClasses );
parser.addArgument( skipRequests );
List extra = parser.parse( args );
// For this application, extra arguments will be treated as a usage error.
if( !extra.isEmpty() || help.getValue())
{
PrintWriter out = new PrintWriter( System.out );
parser.printUsage( out );
out.close();
System.exit( 0 );
}
BooleanArgument,
StringArgument| Constructor Summary | |
ArgumentParser()
|
|
| Method Summary | |
void |
addArgument(Argument arg)
Add a new argument to be taken into consideration during the next parse. |
static void |
main(java.lang.String[] ignored)
Test driver. |
java.util.List |
parse(java.lang.String[] args)
Parses the given argument list according to all Arguments registered with this parser. |
void |
printUsage(java.io.PrintWriter out)
Dumps the usage of each registered argument to out. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public ArgumentParser()
| Method Detail |
public void addArgument(Argument arg)
public void printUsage(java.io.PrintWriter out)
public java.util.List parse(java.lang.String[] args)
public static void main(java.lang.String[] ignored)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||