public class CommandLine
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
LONG_ARG_SEP |
static char |
NON_BREAKING_SPACE |
static java.lang.String |
PREFIX_LONG |
static java.lang.String |
PREFIX_SHORT |
Constructor and Description |
---|
CommandLine(java.lang.Iterable<SwitchOrArgument> switchesOrArguments)
Constructor.
|
CommandLine(SwitchOrArgument... switchesOrArguments)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
static void |
checkLongForm(java.lang.String longForm) |
void |
evaluate(java.util.List<java.lang.String> args)
Evaluate the command line.
|
void |
evaluate(java.lang.String[] args)
Evaluate the command line.
|
java.lang.String |
getUsage(int lineLength,
int indent) |
void |
printUsageAndExit(int exitCode) |
void |
printUsageAndExit(java.io.PrintStream out,
int exitCode) |
public static final java.lang.String PREFIX_SHORT
public static final java.lang.String PREFIX_LONG
public static final java.lang.String LONG_ARG_SEP
public static final char NON_BREAKING_SPACE
public CommandLine(@NotNull SwitchOrArgument... switchesOrArguments)
switchesOrArguments
- switches or arguments used on the command linepublic CommandLine(@NotNull java.lang.Iterable<SwitchOrArgument> switchesOrArguments)
switchesOrArguments
- switches or arguments used on the command linepublic void evaluate(@NotNull java.lang.String[] args) throws UnknownSwitchException, UnexpectedArgumentException, TooManyArgumentsException
args
- command line argumentsUnknownSwitchException
- if an unknown switch appearsUnexpectedArgumentException
- if a long switch not requiring an argument comes with an argumentTooManyArgumentsException
- if there are no more switches or arguments for consuming the command line argspublic void evaluate(@NotNull java.util.List<java.lang.String> args) throws UnknownSwitchException, UnexpectedArgumentException, TooManyArgumentsException
args
- command line argumentsUnknownSwitchException
- if an unknown switch appearsUnexpectedArgumentException
- if a long switch not requiring an argument comes with an argumentTooManyArgumentsException
- if there are no more switches or arguments for consuming the command line argspublic static void checkLongForm(@NotNull java.lang.String longForm)
@NotNull public java.lang.String getUsage(int lineLength, int indent)
public void printUsageAndExit(@NotNull java.io.PrintStream out, int exitCode)
public void printUsageAndExit(int exitCode)