Class Argument
java.lang.Object
io.vertx.core.cli.Argument
- Direct Known Subclasses:
TypedArgument
Defines a command line argument. Unlike options, argument don't have names and are identified using an index. The
first index is 0 (because we are in the computer world).
- Author:
- Clement Escoffier invalid input: '<'[email protected]>
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringThe argument name used in the usage.static final StringThe default argument name displayed in the usage.protected StringThe optional default value of this argument.protected StringThe argument description.protected booleanWhether or not this argument is hidden.protected intThe argument index.protected booleanWhether or not this argument can receive multiple value.protected booleanWhether or not this argument is mandatory. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidChecks that the argument configuration is valid.intgetIndex()booleanisHidden()booleanbooleansetArgName(String argName) Sets the argument name of thisArgument.setDefaultValue(String defaultValue) Sets the default value of thisArgument.setDescription(String description) Sets the description of theArgument.setHidden(boolean hidden) Sets whether or not the currentArgumentis hidden.setIndex(int index) Sets the argument index.setMultiValued(boolean multiValued) Sets whether or not the argument can receive several values.setRequired(boolean required) Sets whether or not the currentArgumentis required.toJson()Exports thisArgumentto its corresponding JSON representation.
-
Field Details
-
DEFAULT_ARG_NAME
The default argument name displayed in the usage.- See Also:
-
index
protected int indexThe argument index. Must be positive or null. It is set fo -1 by default to check that the index was set. -
argName
The argument name used in the usage. -
description
The argument description. -
required
protected boolean requiredWhether or not this argument is mandatory. Mandatory arguments throw aMissingValueExceptionif the user command line does not provide a value. -
defaultValue
The optional default value of this argument. -
multiValued
protected boolean multiValuedWhether or not this argument can receive multiple value. Only the last argument can receive multiple values.
-
-
Constructor Details
-
Method Details
-
toJson
-
getArgName
- Returns:
- the arg name,
nullif not defined.
-
setArgName
-
getDescription
- Returns:
- the description,
nullif not defined.
-
setDescription
-
isHidden
public boolean isHidden()- Returns:
- whether or not the current
Argumentis hidden.
-
setHidden
-
getIndex
public int getIndex()- Returns:
- the argument index.
-
setIndex
-
isRequired
public boolean isRequired()- Returns:
- whether or not the current
Argumentis required.
-
setRequired
-
getDefaultValue
- Returns:
- the argument default value,
nullif not specified.
-
setDefaultValue
-
isMultiValued
public boolean isMultiValued()- Returns:
- whether or not the argument can receive several values.
-
setMultiValued
-
ensureValidity
public void ensureValidity()Checks that the argument configuration is valid. This method is mainly made for children classes adding constraint to the configuration. The parser verifies that arguments are valid before starting the parsing. If the configuration is not valid, this method throws aIllegalArgumentException.
-