Annotation Type CliOption


  • @Retention(RUNTIME)
    @Target({FIELD,ANNOTATION_TYPE})
    public @interface CliOption
    This annotation marks a field as an option of the commandline. Field can be of type:
    • boolean in which case the option must take no value and the field will be set to true if the option is present of false otherwise.
    • String in which case the option must take at least one value and the field will be set to the first value of the option. If option is not present or has no value, the field will be set to null.
    • String[] in which case the option must take zero or more values and the field will be set to an array containing all values of the option. If option is not present or has no value, the field will be set to null.
    • Map<String, String> in which case the option must take an even number of values and the field will be set to a map containing odd option values as keys and even option values as values. If option is not present or has no value, the field will be set to an empty map.
    • Required Element Summary

      Required Elements 
      Modifier and Type Required Element Description
      String name
      The short name of the option.
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      String[] defaultValues
      The default value(s) of the option.
      String description
      The description of the option (used by the help command).
      String longName
      The long name of the option.
      boolean mandatory
      If the option is mandatory.
      boolean mandatoryValue
      If the option values are mandatory.
      int valueCount
      The number of values this option can take (or -1 if unlimited).
      char valueSeparator
      The character for separating option values.
    • Element Detail

      • name

        String name
        The short name of the option.
      • longName

        String longName
        The long name of the option.
        Default:
        ""
      • mandatory

        boolean mandatory
        If the option is mandatory.
        Default:
        false
      • valueCount

        int valueCount
        The number of values this option can take (or -1 if unlimited). Checked only if the option is present in the command line.
        Default:
        0
      • valueSeparator

        char valueSeparator
        The character for separating option values. It can be set to '=' to parse named option values. When providing -Okey1=value1 -Okey2=value2 on the command line, the result can then be injected into a String array containing key/value pairs ([ "key1", "value1", "key2", "value2"]) or directly into a Map<String, String>.
        Default:
        ','
      • mandatoryValue

        boolean mandatoryValue
        If the option values are mandatory. Checked only if the option is present in the command line.
        Default:
        false
      • defaultValues

        String[] defaultValues
        The default value(s) of the option. Used when the option is not mandatory and not present in the command line. Also used when the option is present, its values are not mandatory and are not present in the command line.
        Default:
        {}
      • description

        String description
        The description of the option (used by the help command).
        Default:
        ""