Class OptionSpec

java.lang.Object
com.codename1.cli.ArgSpec
com.codename1.cli.OptionSpec

public final class OptionSpec extends ArgSpec
The model of one option, written by the build from an CommandLine.Option.
  • Constructor Details

    • OptionSpec

      public OptionSpec(int slot, String[] names, String description, String paramLabel, boolean flag, boolean required, String arity, boolean multiple, String defaultValue, String split, boolean negatable, boolean hidden)

      Creates the model of an option.

      Parameters
      • slot: the number the generated binding knows this option by

      • names: every name, such as -v and --verbose

      • description: the help text

      • paramLabel: the placeholder printed for its value, such as <file>

      • flag: true for a boolean that takes no value

      • required: whether a command line without it is an error

      • arity: how many values one occurrence takes, as 1, 0..1 or 1..*; empty for the default

      • multiple: true when the field is an array or a list

      • defaultValue: the value used when the option is absent, or null; ${env:NAME} reads an environment variable

      • split: a separator that splits one value into several, or null

      • negatable: whether --no-<name> sets a flag to false

      • hidden: whether it is left out of the help

  • Method Details

    • names

      public String[] names()
      Every name of the option.
    • longestName

      public String longestName()
      The longest name, which the usage line and error messages print.
    • negatable

      public boolean negatable()
      Whether --no-<name> sets the flag to false.
    • usageHelp

      public boolean usageHelp()
      Whether this is the built-in --help.
    • versionHelp

      public boolean versionHelp()
      Whether this is the built-in --version.