com.neeve.cli.annotations
Annotation Type Option


@Retention(value=RUNTIME)
@Target(value={FIELD,PARAMETER})
public @interface Option

Defines an optional command parameter that can be interleaved with command arguments.

Options can be particularly useful as an alternative to adding additional arguments in cases where backwards compatibility of a command signature needs to be maintained, but can also be used for execution that are optional and have a reasonable default value for most cases.


Required Element Summary
 String longForm
          The long form for the argument (e.g.
 char shortForm
          The short (switch e.g.
 
Optional Element Summary
 String defaultValue
          The option's default value.
 String description
          A brief description of the Option.
 String displayName
          Returns a display name for the option.
 boolean required
          Whether or not the option is required.
 String[] validOptions
          Can be specified to limit the valid options.
 

Element Detail

shortForm

public abstract char shortForm
The short (switch e.g. -o) form for the option.

Returns:
The short (switch) form for the option.

longForm

public abstract String longForm
The long form for the argument (e.g. --option)).

Returns:
The long form for the argument

displayName

public abstract String displayName
Returns a display name for the option.

This value can be used by user interfaces in place of the actual option name. When this value is omitted, the longForm() can be used.

Returns:
A short, friendly display name for the option.
Default:
""

description

public abstract String description
A brief description of the Option.

Returns:
The description of the argument
Default:
""

defaultValue

public abstract String defaultValue
The option's default value. When the option is not specified the option will be set to this value.

Returns:
The option's default value
Default:
""

required

public abstract boolean required
Whether or not the option is required. If the option is not specified but there is a default value, then the default will be used, otherwise it is an error.

Returns:
Whether or not the option is required.
Default:
false

validOptions

public abstract String[] validOptions
Can be specified to limit the valid options.

Returns:
The valid options.
Default:
{}


Copyright © 2016 Neeve Research, LLC. All Rights Reserved.