|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.freehep.util.argv.ArgumentParser
public class 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.
StringOption destination = new StringOption( "-dest", "localhost", "Destination for request tests" );
BooleanOption help = new BooleanOption( "-help", "Describe command line args", true );
// 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.add( destination );
parser.add( skipClasses );
parser.add( 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 );
}
BooleanOption,
StringOption| Constructor Summary | |
|---|---|
ArgumentParser(String name)
|
|
| Method Summary | |
|---|---|
void |
add(Option opt)
Add a new option to be taken into consideration during the next parse. |
void |
add(Parameter param)
|
static void |
main(String[] ignored)
Test driver. |
List |
parse(List args)
Parses the given argument list according to all Options registered with this parser. |
List |
parse(String[] args)
Parses the given argument list according to all Options registered with this parser. |
void |
printUsage(OutputStream out)
Dumps the usage of the program and each parameter and option to out. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ArgumentParser(String name)
| Method Detail |
|---|
public void add(Option opt)
public void add(Parameter param)
public void printUsage(OutputStream out)
public List parse(String[] args)
throws MissingArgumentException,
ArgumentFormatException
MissingArgumentException
ArgumentFormatException
public List parse(List args)
throws MissingArgumentException,
ArgumentFormatException
MissingArgumentException
ArgumentFormatException
public static void main(String[] ignored)
throws MissingArgumentException,
ArgumentFormatException
MissingArgumentException
ArgumentFormatException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||