Package readycli
Class Option
java.lang.Object
readycli.Option
- All Implemented Interfaces:
java.io.Serializable
public final class Option
extends java.lang.Object
implements java.io.Serializable
An option is an argument of a
Command
that can be optionally
specified on command.line. An option is useful to change the default values
of some parameters. These parameters
, if present, succeed
the option name on the command-line. An option with no parameters is called a
flag. To create a new option, the create(String, String)
method must
be invoked.- Author:
- Salvatore Giampa'
- See Also:
- Serialized Form
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Option.Builder
A builder entity used build newoptions
.static class
Option.Parameter
Represents a parameter of anOption
. -
Method Summary
Modifier and Type Method Description static Option.Builder
create(java.lang.String name, java.lang.String description)
Starts the creation of a new command-line option.java.util.List<java.lang.String>
getAliases()
Gets the list of the aliases of this option. the aliases are secondary or shortest names assigned to an option, to simplify its specification on command-line.java.lang.String
getDescription()
Gets the description of the option.java.lang.String
getName()
Gets the name of the option.java.util.List<Option.Parameter>
getParameters()
Gets the list of the option parameters, in the order they were specified during construction.
-
Method Details
-
getName
public java.lang.String getName()Gets the name of the option.- Returns:
- the name of the option as a string
-
getDescription
public java.lang.String getDescription()Gets the description of the option.- Returns:
- the description of the option as a string
-
getParameters
Gets the list of the option parameters, in the order they were specified during construction.- Returns:
- the list of parameters.
-
getAliases
public java.util.List<java.lang.String> getAliases()Gets the list of the aliases of this option. the aliases are secondary or shortest names assigned to an option, to simplify its specification on command-line.- Returns:
- the list of aliases assigned to this option
-
create
Starts the creation of a new command-line option. An option can be specified on the command-line by specifying its name preceded by two consecutive minus ("--") characters.
An option can be accessed from theCommandContext
only through its name as it is specified during the construction of the option.- Parameters:
name
- the name of the optiondescription
- the description of the option- Returns:
- An
Option.Builder
object
-