Interface CommandLine
public interface CommandLine
The parser transforms a CLI (a model) into an
CommandLine. This CommandLine
has stored the argument and option values. Only instance of parser should create
objects of this type.- Author:
- Clement Escoffier invalid input: '<'[email protected]>
-
Method Summary
Modifier and TypeMethodDescriptionbooleanacceptMoreValues(Option option) Checks whether or not the given option accept more values.cli()static CommandLineCreates a command line object from theCLI.<T> TgetArgumentValue(int index) Gets the value of an argument with the given index.<T> TgetArgumentValue(String name) Gets the value of an argument with the matching name (arg name).<T> List<T> getArgumentValues(int index) Gets the values of an argument with the matching index.<T> TgetOptionValue(String name) Gets the value of an option with the matching name (can be the long name, short name or arg name).<T> List<T> getOptionValues(String name) Gets the values of an option with the matching name (can be the long name, short name or arg name).Gets the raw value of the given argument.getRawValueForOption(Option option) Gets the raw value of the given option.getRawValues(Option option) Deprecated.getRawValuesForArgument(Argument argument) Gets the raw values of the given argument.getRawValuesForOption(Option option) Gets the raw values of the given option.booleanChecks whether or not the given argument has been assigned in the command line.booleanChecks whether or not the user has passed a "help" option and is asking for help.booleanisFlagEnabled(String name) Gets the value of an option marked as a flag.booleanisOptionAssigned(Option option) Checks whether or not the given option has been assigned in the command line.booleanisSeenInCommandLine(Option option) Checks whether or not the given option has been seen in the user command line.booleanisValid()Checks whether or not the command line is valid, i.e. all constraints from arguments and options have been satisfied.
-
Method Details
-
create
Creates a command line object from theCLI. This object is intended to be used by the parser to set the argument and option values.- Parameters:
cli- the CLI definition- Returns:
- the command line object
-
cli
CLI cli()- Returns:
- the model of this command line object.
-
allArguments
-
getOptionValue
Gets the value of an option with the matching name (can be the long name, short name or arg name).- Type Parameters:
T- the expected type- Parameters:
name- the name- Returns:
- the value,
nullif not set
-
getArgumentValue
Gets the value of an argument with the matching name (arg name).- Type Parameters:
T- the expected type- Parameters:
name- the name- Returns:
- the value,
nullif not set
-
getArgumentValue
<T> T getArgumentValue(int index) Gets the value of an argument with the given index.- Type Parameters:
T- the expected type- Parameters:
index- the index- Returns:
- the value,
nullif not set
-
getOptionValues
-
getArgumentValues
Gets the values of an argument with the matching index.- Type Parameters:
T- the expected component type- Parameters:
index- the index- Returns:
- the values,
nullif not set - See Also:
-
isFlagEnabled
Gets the value of an option marked as a flag. Calling this method an a non-flag option throws anIllegalStateException.- Parameters:
name- the option name- Returns:
trueif the flag has been set in the command line,falseotherwise.
-
isOptionAssigned
Checks whether or not the given option has been assigned in the command line.- Parameters:
option- the option- Returns:
trueif the option has received a value,} otherwise.invalid @link
{@link false
-
getRawValues
Deprecated.Gets the raw values of the given option. Raw values are simple "String", not converted to the option type.- Parameters:
option- the option- Returns:
- the list of values, empty if none
-
getRawValuesForOption
-
getRawValuesForArgument
-
getRawValueForOption
-
acceptMoreValues
Checks whether or not the given option accept more values.- Parameters:
option- the option- Returns:
-
} if the option accepts more values,
invalid @link
{@link true} otherwise.invalid @link
{@link false
-
getRawValueForArgument
-
isArgumentAssigned
Checks whether or not the given argument has been assigned in the command line.- Parameters:
arg- the argument- Returns:
trueif the argument has received a value,} otherwise.invalid @link
{@link false
-
isSeenInCommandLine
Checks whether or not the given option has been seen in the user command line.- Parameters:
option- the option- Returns:
trueif the user command line has used the option
-
isValid
boolean isValid()Checks whether or not the command line is valid, i.e. all constraints from arguments and options have been satisfied. This method is used when the parser validation is disabled.- Returns:
trueif the currentCommandLineobject is valid.} otherwise.invalid @link
{@link false
-
isAskingForHelp
boolean isAskingForHelp()Checks whether or not the user has passed a "help" option and is asking for help.- Returns:
trueif the user command line has enabled a "Help" option,} otherwise.invalid @link
{@link false
-
getRawValuesForOption(Option)