Top Description Fields Constructors Methods
io.vertx.core.cli.impl

public Class DefaultCommandLine

extends Object
implements CommandLine
Class Inheritance
All Implemented Interfaces
io.vertx.core.cli.CommandLine
Imports
io.vertx.core.cli.*, io.vertx.core.cli.converters.Converters, java.util.*, java.util.stream.Collectors

Default implementation of the CommandLine. This implementation is not thread-safe.
Author
Clement Escoffier

Field Summary

Modifier and TypeField and Description
protected List<String>
protected Map<Argument, List<String>>
protected final CLI
protected List<Option>
protected Map<Option, List<String>>
protected boolean

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
acceptMoreValues(Option
the option
option
)

Implements io.vertx.core.cli.CommandLine.acceptMoreValues.

Checks whether or not the given option accept more values.

public CommandLine

Returns:

the current instance of DefaultCommandLine.
addArgumentValue
(String
the argument
argument
)

Adds an argument value.

public DefaultCommandLine
addRawValue(Option option, String value)

public List<String>

Returns:

the ordered list of not recognized arguments. Unrecognized arguments are command line arguments matching neither known options or defined arguments.
allArguments
()

Implements io.vertx.core.cli.CommandLine.allArguments.

public CLI

Returns:

the model of this command line object.
cli
()

Implements io.vertx.core.cli.CommandLine.cli.

public static <T> T

Returns:

the created value
create
(String
the value
value
,
TypedArgument<T> argument)

Creates the value for the given argument from the given raw value.

public static <T> T

Returns:

the created value
create
(String
the value
value
,
TypedOption<T> option)

Creates the value for the given option from the given raw value.

public static <T> List<T>
public <T> T
getArgumentValue(String
the name
name
)

Implements io.vertx.core.cli.CommandLine.getArgumentValue.

Gets the value of an argument with the matching name (arg name).

public <T> T
getArgumentValue(int
the index
index
)

Implements io.vertx.core.cli.CommandLine.getArgumentValue.

Gets the value of an argument with the given index.

public <T> List<T>

Returns:

the values, null if not set
getArgumentValues
(int
the index
index
)

Implements io.vertx.core.cli.CommandLine.getArgumentValues.

Gets the values of an argument with the matching index.

public <T> T
getOptionValue(String
the name
name
)

Implements io.vertx.core.cli.CommandLine.getOptionValue.

Gets the value of an option with the matching name (can be the long name, short name or arg name).

public <T> List<T>
getOptionValues(String
the name
name
)

Implements io.vertx.core.cli.CommandLine.getOptionValues.

Gets the values of an option with the matching name (can be the long name, short name or arg name).

public String
getRawValueForArgument(Argument
the argument
arg
)

Implements io.vertx.core.cli.CommandLine.getRawValueForArgument.

Gets the raw value of the given argument.

public String
getRawValueForOption(Option
the option
option
)

Implements io.vertx.core.cli.CommandLine.getRawValueForOption.

Gets the raw value of the given option.

public List<String>
getRawValuesForArgument(Argument
the argument
argument
)

Implements io.vertx.core.cli.CommandLine.getRawValuesForArgument.

Gets the raw values of the given argument.

public List<String>
getRawValuesForOption(Option
the option
option
)

Implements io.vertx.core.cli.CommandLine.getRawValuesForOption.

Gets the raw values of the given option.

private <T> T
getValue(TypedOption<T> option)

public boolean
isArgumentAssigned(Argument
the argument
arg
)

Implements io.vertx.core.cli.CommandLine.isArgumentAssigned.

Checks whether or not the given argument has been assigned in the command line.

public boolean

Returns:

true if the user command line has enabled a "Help" option, false otherwise.
isAskingForHelp
()

Implements io.vertx.core.cli.CommandLine.isAskingForHelp.

Checks whether or not the user has passed a "help" option and is asking for help.

private boolean
public boolean
isFlagEnabled(String
the option name
name
)

Implements io.vertx.core.cli.CommandLine.isFlagEnabled.

Gets the value of an option marked as a flag.

public boolean
isOptionAssigned(Option
the option
option
)

Implements io.vertx.core.cli.CommandLine.isOptionAssigned.

Checks whether or not the given option has been assigned in the command line.

public boolean
isSeenInCommandLine(Option
the option
option
)

Implements io.vertx.core.cli.CommandLine.isSeenInCommandLine.

Checks whether or not the given option has been seen in the user command line.

public boolean

Returns:

true if the current CommandLine object is valid. false otherwise.
isValid
()

Implements io.vertx.core.cli.CommandLine.isValid.

Checks whether or not the command line is valid, i.e. all constraints from arguments and options have been satisfied.

public DefaultCommandLine
setRawValue(Argument arg, String rawValue)

public DefaultCommandLine

Returns:

the current instance of DefaultCommandLine.
setSeenInCommandLine
(Option
the option
option
)

Marks the option as seen.

pack-priv void
setValidity(boolean
true if the command line is valid.
validity
)

Sets whether or not the CommandLine is valid.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

allArgsback to summary
protected List<String> allArgs
argumentValuesback to summary
protected Map<Argument, List<String>> argumentValues
cliback to summary
protected final CLI cli
optionsSeenInCommandLineback to summary
protected List<Option> optionsSeenInCommandLine
optionValuesback to summary
protected Map<Option, List<String>> optionValues
validback to summary
protected boolean valid

Constructor Detail

DefaultCommandLineback to summary
public DefaultCommandLine(CLI cli)

Method Detail

acceptMoreValuesback to summary
public boolean acceptMoreValues(Option option)

Implements io.vertx.core.cli.CommandLine.acceptMoreValues.

Doc from io.vertx.core.cli.CommandLine.acceptMoreValues.

Checks whether or not the given option accept more values.

Parameters
option:Option

the option

Returns:boolean

true if the option accepts more values, false otherwise.

Annotations
@Override
addArgumentValueback to summary
public CommandLine addArgumentValue(String argument)

Adds an argument value.

Parameters
argument:String

the argument

Returns:CommandLine

the current instance of DefaultCommandLine.

addRawValueback to summary
public DefaultCommandLine addRawValue(Option option, String value)
allArgumentsback to summary
public List<String> allArguments()

Implements io.vertx.core.cli.CommandLine.allArguments.

Returns:List<String>

the ordered list of not recognized arguments. Unrecognized arguments are command line arguments matching neither known options or defined arguments.

Annotations
@Override
cliback to summary
public CLI cli()

Implements io.vertx.core.cli.CommandLine.cli.

Returns:CLI

the model of this command line object.

Annotations
@Override
createback to summary
public static <T> T create(String value, TypedArgument<T> argument)

Creates the value for the given argument from the given raw value.

Parameters
value:String

the value

Returns:T

the created value

createback to summary
public static <T> T create(String value, TypedOption<T> option)

Creates the value for the given option from the given raw value.

Parameters
value:String

the value

Returns:T

the created value

createFromListback to summary
public static <T> List<T> createFromList(String raw, TypedOption<T> option)
getArgumentValueback to summary
public <T> T getArgumentValue(String name)

Implements io.vertx.core.cli.CommandLine.getArgumentValue.

Doc from io.vertx.core.cli.CommandLine.getArgumentValue.

Gets the value of an argument with the matching name (arg name).

Parameters
<T>
the expected type
name:String

the name

Returns:T

the value, null if not set

Annotations
@Override
getArgumentValueback to summary
public <T> T getArgumentValue(int index)

Implements io.vertx.core.cli.CommandLine.getArgumentValue.

Doc from io.vertx.core.cli.CommandLine.getArgumentValue.

Gets the value of an argument with the given index.

Parameters
<T>
the expected type
index:int

the index

Returns:T

the value, null if not set

Annotations
@Override
@SuppressWarnings:unchecked
getArgumentValuesback to summary
public <T> List<T> getArgumentValues(int index)

Implements io.vertx.core.cli.CommandLine.getArgumentValues.

Gets the values of an argument with the matching index.

Parameters
<T>

Doc from io.vertx.core.cli.CommandLine.getArgumentValues. the expected component type

index:int

the index

Returns:List<T>

the values, null if not set

Annotations
@Override
@SuppressWarnings:unchecked
See Also
getArgumentValue(int), getRawValueForArgument(Argument)
getOptionValueback to summary
public <T> T getOptionValue(String name)

Implements io.vertx.core.cli.CommandLine.getOptionValue.

Doc from io.vertx.core.cli.CommandLine.getOptionValue.

Gets the value of an option with the matching name (can be the long name, short name or arg name).

Parameters
<T>
the expected type
name:String

the name

Returns:T

the value, null if not set

Annotations
@Override
@SuppressWarnings:unchecked
getOptionValuesback to summary
public <T> List<T> getOptionValues(String name)

Implements io.vertx.core.cli.CommandLine.getOptionValues.

Doc from io.vertx.core.cli.CommandLine.getOptionValues.

Gets the values of an option with the matching name (can be the long name, short name or arg name).

Parameters
<T>
the expected component type
name:String

the name

Returns:List<T>

the values, null if not set

Annotations
@Override
@SuppressWarnings:unchecked
getRawValueForArgumentback to summary
public String getRawValueForArgument(Argument arg)

Implements io.vertx.core.cli.CommandLine.getRawValueForArgument.

Doc from io.vertx.core.cli.CommandLine.getRawValueForArgument.

Gets the raw value of the given argument. Raw values are the values as given in the user command line.

Parameters
arg:Argument

the argument

Returns:String

the value, null if none.

Annotations
@Override
getRawValueForOptionback to summary
public String getRawValueForOption(Option option)

Implements io.vertx.core.cli.CommandLine.getRawValueForOption.

Doc from io.vertx.core.cli.CommandLine.getRawValueForOption.

Gets the raw value of the given option. Raw values are the values as given in the user command line.

Parameters
option:Option

the option

Returns:String

the value, null if none.

Annotations
@Override
getRawValuesForArgumentback to summary
public List<String> getRawValuesForArgument(Argument argument)

Implements io.vertx.core.cli.CommandLine.getRawValuesForArgument.

Doc from io.vertx.core.cli.CommandLine.getRawValuesForArgument.

Gets the raw values of the given argument. Raw values are simple "String", not converted to the argument type.

Parameters
argument:Argument

the argument

Returns:List<String>

the list of values, empty if none

Annotations
@Override
getRawValuesForOptionback to summary
public List<String> getRawValuesForOption(Option option)

Implements io.vertx.core.cli.CommandLine.getRawValuesForOption.

Doc from io.vertx.core.cli.CommandLine.getRawValuesForOption.

Gets the raw values of the given option. Raw values are simple "String", not converted to the option type.

Parameters
option:Option

the option

Returns:List<String>

the list of values, empty if none

Annotations
@Override
getValueback to summary
private <T> T getValue(TypedOption<T> option)
isArgumentAssignedback to summary
public boolean isArgumentAssigned(Argument arg)

Implements io.vertx.core.cli.CommandLine.isArgumentAssigned.

Doc from io.vertx.core.cli.CommandLine.isArgumentAssigned.

Checks whether or not the given argument has been assigned in the command line.

Parameters
arg:Argument

the argument

Returns:boolean

true if the argument has received a value, false otherwise.

Annotations
@Override
isAskingForHelpback to summary
public boolean isAskingForHelp()

Implements io.vertx.core.cli.CommandLine.isAskingForHelp.

Checks whether or not the user has passed a "help" option and is asking for help.

Returns:boolean

true if the user command line has enabled a "Help" option, false otherwise.

Annotations
@Override
isBooleanback to summary
private boolean isBoolean(TypedOption<T> option)
isFlagEnabledback to summary
public boolean isFlagEnabled(String name)

Implements io.vertx.core.cli.CommandLine.isFlagEnabled.

Doc from io.vertx.core.cli.CommandLine.isFlagEnabled.

Gets the value of an option marked as a flag.

Calling this method an a non-flag option throws an IllegalStateException.

Parameters
name:String

the option name

Returns:boolean

true if the flag has been set in the command line, false otherwise.

Annotations
@Override
isOptionAssignedback to summary
public boolean isOptionAssigned(Option option)

Implements io.vertx.core.cli.CommandLine.isOptionAssigned.

Doc from io.vertx.core.cli.CommandLine.isOptionAssigned.

Checks whether or not the given option has been assigned in the command line.

Parameters
option:Option

the option

Returns:boolean

true if the option has received a value, false otherwise.

Annotations
@Override
isSeenInCommandLineback to summary
public boolean isSeenInCommandLine(Option option)

Implements io.vertx.core.cli.CommandLine.isSeenInCommandLine.

Doc from io.vertx.core.cli.CommandLine.isSeenInCommandLine.

Checks whether or not the given option has been seen in the user command line.

Parameters
option:Option

the option

Returns:boolean

true if the user command line has used the option

Annotations
@Override
isValidback to summary
public boolean isValid()

Implements io.vertx.core.cli.CommandLine.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:boolean

true if the current CommandLine object is valid. false otherwise.

Annotations
@Override
setRawValueback to summary
public DefaultCommandLine setRawValue(Argument arg, String rawValue)
setSeenInCommandLineback to summary
public DefaultCommandLine setSeenInCommandLine(Option option)

Marks the option as seen.

Parameters
option:Option

the option

Returns:DefaultCommandLine

the current instance of DefaultCommandLine.

setValidityback to summary
pack-priv void setValidity(boolean validity)

Sets whether or not the CommandLine is valid.

Parameters
validity:boolean

true if the command line is valid.