Package com.github.hypfvieh.cli.parser
Klasse CmdArgOption<T>
java.lang.Object
com.github.hypfvieh.cli.parser.CmdArgOption<T>
- Typparameter:
T- data type of the option
Describes a command-line option.
Options are created using the associated
Options are created using the associated
CmdArgOption.Builder.
Sample Usage:
CmdArgOption<ITransformer> optImpl = CmdArgOption.builder(ITransformer.class)
.name("transformerClass")
.description("FQCN of transformer implementation")
.required(true)
.build();
CommandLine cli = new CommandLine().addOptions(optImpl);
// ...
cli.parse(args);
if (cli.hasOption(optImpl)) {
ITransformer transformer = cli.getArg(optImpl);
// ...
}
- Seit:
- 1.0.0 - 2022-04-19
- Autor:
- David M., Markus S.
-
Verschachtelte Klassen - Übersicht
Verschachtelte KlassenModifizierer und TypKlasseBeschreibungstatic final classBuilder for a command-line option.
The builder guarantees the option it builds is valid.
At a minimum an option requires a name. -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungstatic CmdArgOption.Builder<Void> builder()Returns a builder for a new option without value (therefore default value not permitted).static <T> CmdArgOption.Builder<T> Returns a builder for a new option with the specified data type.
As the data type is specified, the option must have a value (and may have a default value).booleanClass<?> Returns the type of data to create from argument.Returns the default value for this option (when option was not set).Returns the description text for this option.getName()Returns the long name of this optionA map containing all values (and description) allowed for this option.Returns the short name of this option.inthashCode()booleanhasValue()Flag to signal if the option requires a value.booleanFlag to signal that this option is optional.booleanFlag to allow the option to be repeated multiple times.booleanFlag to signal if this option is required.toString()
-
Methodendetails
-
getName
Returns the long name of this option- Gibt zurück:
- String, maybe null or empty
-
getShortName
Returns the short name of this option.- Gibt zurück:
- String, maybe empty or null
-
getDescription
Returns the description text for this option.- Gibt zurück:
- String, maybe empty or null
-
isRequired
public boolean isRequired()Flag to signal if this option is required.- Gibt zurück:
- true if required
-
isRepeatable
public boolean isRepeatable()Flag to allow the option to be repeated multiple times.- Gibt zurück:
- true if repeatable
-
isOptional
public boolean isOptional()Flag to signal that this option is optional.- Gibt zurück:
- true if optional
-
hasValue
public boolean hasValue()Flag to signal if the option requires a value.- Gibt zurück:
- true if value required
-
getDefaultValue
Returns the default value for this option (when option was not set).- Gibt zurück:
- default value, maybe null
-
getPossibleValues
A map containing all values (and description) allowed for this option.- Gibt zurück:
- Map, maybe empty never null
-
getDataType
Returns the type of data to create from argument.- Gibt zurück:
- class, maybe null
-
hashCode
public int hashCode() -
equals
-
toString
-
builder
Returns a builder for a new option with the specified data type.
As the data type is specified, the option must have a value (and may have a default value).- Typparameter:
T- data type of the option- Parameter:
_dataType- data type of option- Gibt zurück:
- builder
-
builder
Returns a builder for a new option without value (therefore default value not permitted).- Gibt zurück:
- builder
-