Package groovy.cli
Annotation Type Option
@Documented
@Retention(RUNTIME)
@Target({METHOD,FIELD})
public @interface Option
Indicates that a method or property can be used to set a CLI option.
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description java.lang.ClassconvertA conversion closure to convert the incoming String into the desired objectjava.lang.StringdefaultValueThe default value for this option as a String; subject to type conversion and 'convert'.java.lang.StringdescriptionThe description of this optionjava.lang.StringlongNameThe long name of this option.intnumberOfArgumentsHow many arguments this option has.java.lang.StringnumberOfArgumentsStringHow many arguments this option has represented as a String.booleanoptionalArgWhether this option can have an optional argument.java.lang.StringshortNameThe short name of this option.java.lang.StringvalueSeparatorThe value separator for this multi-valued option.
-
Element Details
-
description
java.lang.String descriptionThe description of this option- Returns:
- the description of this option
- Default:
- ""
-
shortName
java.lang.String shortNameThe short name of this option. Defaults to the name of member being annotated if the longName is empty.- Returns:
- the short name of this option
- Default:
- ""
-
longName
java.lang.String longNameThe long name of this option. Defaults to the name of member being annotated.- Returns:
- the long name of this option
- Default:
- ""
-
valueSeparator
java.lang.String valueSeparatorThe value separator for this multi-valued option. Only allowed for array-typed arguments.- Returns:
- the value separator for this multi-valued option
- Default:
- ""
-
optionalArg
boolean optionalArgWhether this option can have an optional argument. Only supported for array-typed arguments to indicate that the array may be empty.- Returns:
- true if this array-typed option can have an optional argument (i.e. could be empty)
- Default:
- false
-
numberOfArguments
int numberOfArgumentsHow many arguments this option has. A value greater than 1 is only allowed for array-typed arguments. Ignored for boolean options which are assumed to have a default of 0 or ifnumberOfArgumentsStringis set.- Returns:
- the number of arguments
- Default:
- 1
-
numberOfArgumentsString
java.lang.String numberOfArgumentsStringHow many arguments this option has represented as a String. Only allowed for array-typed arguments. OverridesnumberOfArgumentsif set. The special values of '+' means one or more and '*' as 0 or more.- Returns:
- the number of arguments (as a String)
- Default:
- ""
-
defaultValue
java.lang.String defaultValueThe default value for this option as a String; subject to type conversion and 'convert'. Ignored for Boolean options.- Returns:
- the default value for this option
- Default:
- ""
-
convert
java.lang.Class convertA conversion closure to convert the incoming String into the desired object- Returns:
- the closure to convert this option's argument(s)
- Default:
- groovy.transform.Undefined.CLASS.class
-