org.springframework.shell.core.annotation
Annotation Type CliOption


@Retention(value=RUNTIME)
@Target(value=PARAMETER)
public @interface CliOption

Annotates the arguments of a command methods, allowing it to declare the argument value as mandatory or optional with a default value.

Since:
1.0

Required Element Summary
 String[] key
           
 
Optional Element Summary
 String help
           
 boolean mandatory
           
 String optionContext
          Returns a string providing context-specific information (e.g. a comma-delimited set of keywords) to the Converter that handles the annotated parameter's type.
 String specifiedDefaultValue
           
 boolean systemProvided
           
 String unspecifiedDefaultValue
           
 

Element Detail

key

public abstract String[] key
Returns:
the name of the option, which must be unique within this CliCommand (an empty String may be given, which would denote this option is the default for the command)

systemProvided

public abstract boolean systemProvided
Returns:
if true, the user cannot specify this option and it is provided by the shell infrastructure (defaults to false)
Default:
false

mandatory

public abstract boolean mandatory
Returns:
true if this option must be specified one way or the other by the user (defaults to false)
Default:
false

unspecifiedDefaultValue

public abstract String unspecifiedDefaultValue
Returns:
the default value to use if this option is unspecified by the user (defaults to __NULL__, which causes null to be presented to any non-primitive parameter)
Default:
"__NULL__"

specifiedDefaultValue

public abstract String specifiedDefaultValue
Returns:
the default value to use if this option is included by the user, but they didn't specify an actual value (most commonly used for flags; defaults to __NULL__, which causes null to be presented to any non-primitive parameter)
Default:
"__NULL__"

optionContext

public abstract String optionContext
Returns a string providing context-specific information (e.g. a comma-delimited set of keywords) to the Converter that handles the annotated parameter's type.

For example, if a method parameter "thing" of type "Thing" is annotated as follows:

@CliOption(..., optionContext = "foo,bar", ...) Thing thing
... then the Converter that converts the text entered by the user into an instance of Thing will be passed "foo,bar" as the value of the optionContext parameter in its public methods. This allows the behaviour of that Converter to be individually customised for each CliOption of each CliCommand.

Returns:
a non-null string (can be empty)
Default:
""

help

public abstract String help
Returns:
a help message for this option (the default is a blank String, which means there is no help)
Default:
""