public final class CommandLine extends Object
OptionProcessor
s
and declarative options
.Modifier and Type | Method | Description |
---|---|---|
static CommandLine |
create(Class<?>... classes) |
Creates new command line processor based on options defined in
the provided
classes . |
static CommandLine |
getDefault() |
Getter for the default command line processor in the system.
|
void |
process(String... args) |
Process the array of arguments and invoke associated
OptionProcessor s. |
void |
process(String[] args,
InputStream is,
OutputStream os,
OutputStream err,
File currentDir) |
Process the array of arguments and invoke associated
OptionProcessor s. |
void |
usage(PrintWriter w) |
Prints the usage information about options provided by associated
OptionProcessor s. |
public static CommandLine getDefault()
OptionProcessor
s is taken from default
Lookup.getDefault()
.public static CommandLine create(Class<?>... classes)
classes
. These classes are scanned for
fields annotated with @
Arg
annotation.classes
- classes that declare the optionspublic void process(String... args) throws CommandException
OptionProcessor
s.args
- the array of strings to processCommandException
- if processing is not possible or failedpublic void process(String[] args, InputStream is, OutputStream os, OutputStream err, File currentDir) throws CommandException
OptionProcessor
s.args
- the array of strings to processis
- the input stream that processors can reados
- the output stream that processors can write toerr
- the output stream that processors can send error messages tocurrentDir
- directory that processors should use as current user dirCommandException
- if processing is not possible or failedpublic void usage(PrintWriter w)
OptionProcessor
s.w
- the writer to output usage info toBuilt on April 24 2018. | Portions Copyright 1997-2018 Oracle. All rights reserved.