public final class CmdLine
extends java.lang.Object
| Constructor and Description |
|---|
CmdLine(java.lang.Iterable<java.lang.String> args)
Construct
CmdLine. |
CmdLine(java.lang.String[] args)
Construct
CmdLine. |
| Modifier and Type | Method and Description |
|---|---|
void |
eval()
Evaluate the command line and invoke the corresponding actions.
|
CmdLineAction |
namedOptionAction(java.util.function.BiConsumer<java.lang.String,java.lang.String> consumer)
Register a named option action.
|
CmdLineAction |
switchAction(java.util.function.Consumer<java.lang.String> consumer)
Register a switch action.
|
java.lang.String |
toString() |
void |
unknownArgument(java.util.function.Consumer<java.lang.String> consumer)
Register an action for unknown arguments.
|
void |
unnamedOptionAction(java.util.function.Consumer<java.lang.String> consumer)
Register an unnamed option action.
|
public CmdLine(java.lang.String[] args)
CmdLine.args - The command line to evaluate.public CmdLine(java.lang.Iterable<java.lang.String> args)
CmdLine.args - The command line to evaluate.public void eval()
throws CmdLineException
CmdLineException - If one of the actions fails with a CmdLineActionException.public CmdLineAction switchAction(java.util.function.Consumer<java.lang.String> consumer)
consumer - The consumer to be invoked with the argument if this action matches during command line
evaluation.CmdLineActionpublic CmdLineAction namedOptionAction(java.util.function.BiConsumer<java.lang.String,java.lang.String> consumer)
consumer - The consumer to be invoked with the argument and the option if this action matches during command
line evaluation.CmdLineActionpublic void unnamedOptionAction(java.util.function.Consumer<java.lang.String> consumer)
consumer - The consumer to be invoked with the option if this action matches during command line evaluation.public void unknownArgument(java.util.function.Consumer<java.lang.String> consumer)
consumer - The consumer to be invoked if an argument is encountered during evaluation which matches no
action.public java.lang.String toString()
toString in class java.lang.Object