SimpleCLIParser
is my current preferred implementation.
It's a lot simpler: there's no need for handler objects,
and the options are processed by the constructor. However,
I still have code that depends on this class, so it will
stick around until the (never expected) 2.0 release.@Deprecated public abstract class CommandLineProcessor extends Object
The program's main()
will instantiate the subclass and
then call process(java.lang.String[])
.
At the present time, this class does not support combined arguments. However, since they will be passed to the subclass' default method, it can handle them if needed.
Modifier and Type | Class and Description |
---|---|
protected static interface |
CommandLineProcessor.OptionHandler
Deprecated.
Subclass-defined argument handlers must implement this interface.
|
Constructor and Description |
---|
CommandLineProcessor()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addHandler(CommandLineProcessor.OptionHandler handler)
Deprecated.
Adds an option handler to the list.
|
protected void |
handleUnprocessedArguments(List<String> args)
Deprecated.
This method is called after all options have been handled.
|
void |
process(String[] argv)
Deprecated.
Processes the command-line options.
|
public void process(String[] argv)
handleUnprocessedArguments(java.util.List<java.lang.String>)
.protected void addHandler(CommandLineProcessor.OptionHandler handler)
protected void handleUnprocessedArguments(List<String> args)
Note: the "unprocessed" arguments may appear anywhere in the command line. It is essentially the full list of arguments, minus any that represent options or their consumed arguments.
Default behavior is to ignore unprocessed arguments. This exists primarily to simplify test classes, although I suppose some weird program might not have any command-line arguments that aren't tied to an option.