Package readycli
Class Option.Builder
java.lang.Object
readycli.Option.Builder
- Enclosing class:
- Option
public static class Option.Builder
extends java.lang.Object
A builder entity used build new
options
.- Author:
- Salvatore Giampa'
-
Method Summary
Modifier and Type Method Description Option.Builder
addAlias(java.lang.String alias)
Add an alias for the option.Option.Builder
addAliases(java.lang.String... aliases)
Add aliases for the option.Option.Builder
addParameter(java.lang.String name, java.lang.String description, java.lang.String defaultValue)
Add a parameter to the option.Option
build()
Definitely builds the option.
-
Method Details
-
addAlias
Add an alias for the option. An option can be specified on the command-line through an alias by specifying the name of that alias preceded by a single minus ('-') character.
For example, given an option "test":- the option name is "my-option";
- an alias of the option is "myo";
- another alias of the option is "o";
- --my-option followed by option parameters
- -myo followed by option parameters
- -o followed by option parameters
CommandContext
only through its name ("my-option", in the previous example) as it is specified during the construction of the option.- Parameters:
alias
- the name of the alias- Returns:
- this
Option.Builder
-
addAliases
Add aliases for the option. Invoking this method, is equivalent to invoke theaddAlias(String)
method on each string passed to this one.- Parameters:
aliases
- the names of the aliases to add. If the array is empty, no alias is added to the option and no exception is thrown.- Returns:
- this
Option.Builder
- See Also:
addAlias(String)
-
addParameter
public Option.Builder addParameter(java.lang.String name, java.lang.String description, java.lang.String defaultValue)Add a parameter to the option.- Parameters:
name
- the name of the parameterdescription
- the description of the parameterdefaultValue
- the default value assumed by the parameter in the case the option is not specified on the command-line- Returns:
- this
Option.Builder
-
build
Definitely builds the option.- Returns:
- the new
Option
object
-