Top Description Methods
io.vertx.core.cli

public Interface CommandLine

Known Direct Implementers
io.vertx.core.cli.impl.DefaultCommandLine
Annotations
@VertxGen
Imports
io.vertx.codegen.annotations.GenIgnore, .Nullable, .VertxGen, io.vertx.core.cli.impl.DefaultCommandLine, java.util.List

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

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the option accepts more values, false otherwise.
acceptMoreValues
(Option
the option
option
)

Checks whether or not the given option accept more values.

public List<String>

Returns:

the ordered list of arguments. Arguments are command line arguments not matching an option.
allArguments
()

public CLI

Returns:

the model of this command line object.
cli
()

public static CommandLine

Returns:

the command line object
create
(CLI
the CLI definition
cli
)

Creates a command line object from the CLI.

public <
the expected type
T
>
@Nullable T

Returns:

the value, null if not set
getArgumentValue
(String
the name
name
)

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

public <
the expected type
T
>
@Nullable T

Returns:

the value, null if not set
getArgumentValue
(int
the index
index
)

Gets the value of an argument with the given index.

public <
the expected component type
T
>
List<T>

Returns:

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

Gets the values of an argument with the matching index.

public <
the expected type
T
>
@Nullable T

Returns:

the value, null if not set
getOptionValue
(String
the name
name
)

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

public <
the expected component type
T
>
List<T>

Returns:

the values, null if not set
getOptionValues
(String
the name
name
)

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

public @Nullable String

Returns:

the value, null if none.
getRawValueForArgument
(Argument
the argument
arg
)

Gets the raw value of the given argument.

public @Nullable String

Returns:

the value, null if none.
getRawValueForOption
(Option
the option
option
)

Gets the raw value of the given option.

public default List<String>

Returns:

the list of values, empty if none
getRawValues
(Option
the option
option
)

Gets the raw values of the given option.

public List<String>

Returns:

the list of values, empty if none
getRawValuesForArgument
(Argument
the argument
argument
)

Gets the raw values of the given argument.

public List<String>

Returns:

the list of values, empty if none
getRawValuesForOption
(Option
the option
option
)

Gets the raw values of the given option.

public boolean

Returns:

true if the argument has received a value, false otherwise.
isArgumentAssigned
(Argument
the argument
arg
)

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
()

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

public boolean

Returns:

true if the flag has been set in the command line, false otherwise.
isFlagEnabled
(String
the option name
name
)

Gets the value of an option marked as a flag.

public boolean

Returns:

true if the option has received a value, false otherwise.
isOptionAssigned
(Option
the option
option
)

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

public boolean

Returns:

true if the user command line has used the option
isSeenInCommandLine
(Option
the option
option
)

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
()

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

Method Detail

acceptMoreValuesback to summary
public boolean acceptMoreValues(Option option)

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.

allArgumentsback to summary
public List<String> allArguments()
Returns:List<String>

the ordered list of arguments. Arguments are command line arguments not matching an option.

cliback to summary
public CLI cli()
Returns:CLI

the model of this command line object.

createback to summary
public static CommandLine create(CLI cli)

Creates a command line object from the CLI. This object is intended to be used by the parser to set the argument and option values.

Parameters
cli:CLI

the CLI definition

Returns:CommandLine

the command line object

getArgumentValueback to summary
public <T> @Nullable T getArgumentValue(String name)

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

Parameters
<T>
the expected type
name:String

the name

Returns:@Nullable T

the value, null if not set

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

Gets the value of an argument with the given index.

Parameters
<T>
the expected type
index:int

the index

Returns:@Nullable T

the value, null if not set

getArgumentValuesback to summary
public <T> List<T> getArgumentValues(int index)

Gets the values of an argument with the matching index.

Parameters
<T>
the expected component type
index:int

the index

Returns:List<T>

the values, null if not set

Annotations
@GenIgnore
See Also
getArgumentValue(int), getRawValueForArgument(Argument)
getOptionValueback to summary
public <T> @Nullable T getOptionValue(String name)

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:@Nullable T

the value, null if not set

getOptionValuesback to summary
public <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).

Parameters
<T>
the expected component type
name:String

the name

Returns:List<T>

the values, null if not set

Annotations
@GenIgnore
See Also
getRawValuesForOption(Option)
getRawValueForArgumentback to summary
public @Nullable String getRawValueForArgument(Argument arg)

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:@Nullable String

the value, null if none.

getRawValueForOptionback to summary
public @Nullable String getRawValueForOption(Option option)

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:@Nullable String

the value, null if none.

getRawValuesback to summary
public default List<String> getRawValues(Option option)

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
@Deprecated
getRawValuesForArgumentback to summary
public List<String> getRawValuesForArgument(Argument argument)

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

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

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

isArgumentAssignedback to summary
public boolean isArgumentAssigned(Argument arg)

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.

isAskingForHelpback to summary
public boolean 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.

isFlagEnabledback to summary
public boolean isFlagEnabled(String name)

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.

isOptionAssignedback to summary
public boolean isOptionAssigned(Option option)

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.

isSeenInCommandLineback to summary
public boolean isSeenInCommandLine(Option option)

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

isValidback to summary
public 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:boolean

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