@Retention(value=RUNTIME) @Documented @Target(value={FIELD,METHOD}) public @interface CliOption
CliOption
is used to annotate a property (member variable of some class or setter-method) that should be
set from a main-program via a commandline option. Field
it may NOT be static
or final
and by convention it should be
private
. Setters may NOT be static
and by convention they should be public
. null
. CliOption
can be triggered via its name
or one of its
aliases
. Options with a type other than boolean
need to be followed by a value as CLI
parameter. This value has to be quoted in the commandline if it contains whitespaces or other characters that are
interpreted by the shell (e.g. backslash in Unix). Type | Comment |
---|---|
String |
The given text as is. |
boolean | Set to true if CliOption is present. Should be initialized with false at construction.
|
Boolean |
If the option is present with a value of true or false the according Boolean is applied.
Otherwise values are treated as invalid. According to CliStyle , true may be omitted. |
Number |
The subclasses of Number from the package java.lang are always supported. |
File |
A file created from the value of the option. |
Enum |
A concrete subclass of Enum . The value needs to match the Enum.name() but
case is ignored and underscores may also be replaced by hyphen ("-") or whitespace (" "). |
ComposedValueConverter
Modifier and Type | Fields and Description |
---|---|
static String |
ALIAS_HELP
The
alias of the option to get help/usage. |
static String |
ALIAS_VERSION
The
alias of the option to get the program version. |
static String |
NAME_HELP
The
name() of the option to get help/usage. |
static String |
NAME_VERBOSE
The
name() of the option for verbose output. |
static String |
NAME_VERSION
The
name() of the option to get the program version. |
static String |
OPERAND_DEFAULT
The default
operand . |
Modifier and Type | Required Element and Description |
---|---|
String |
name
The actual option (e.g.
|
String |
usage
The description of this option for
help usage . |
Modifier and Type | Optional Element and Description |
---|---|
String[] |
aliases
The list of optional aliases that can be used instead of the
name() . |
CliContainerStyle |
containerStyle
The
style of this option if it has a container type. |
String |
mode
|
String |
operand
The name of the operand for the
usage . |
boolean |
required
The flag that indicates if this option is required.
|
public abstract String name
public abstract String usage
help usage
. It should be an
internationalized message
that will be
localized using NlsMessage
.
NLS-arguments
are "operand" for the localized
operand
and "default" for the default value.public abstract boolean required
true
to make this option required within
it's mode
.CliMode.parentIds()
public abstract String mode
ID
of the mode
. A typical main-program has different modes how it can be
invoked. options
of a program can be split into groups that represent such mode. The options are
ordered by their mode in the help-usage-output and modes allow to express that an option
is
required
only in a specific mode. Options
can only be combined as command-line arguments if their modes
are
compatible. This means that the modes have to be identical or one mode extends
the
other. In the latter case the most special mode is triggered. For each mode
that is used in an
CLI annotated class
an according CliMode
annotation has to be present in order to define
the mode.CliMode
public abstract CliContainerStyle containerStyle
style
of this option if it has a container type. The default is
CliContainerStyle.DEFAULT
.CliStyle.containerStyle()
Copyright © 2001–2016 mmm-Team. All rights reserved.