Class CmdArgOption.Builder<T>

java.lang.Object
com.github.hypfvieh.cli.parser.CmdArgOption.Builder<T>
Enclosing class:
CmdArgOption<T>

public static final class CmdArgOption.Builder<T> extends Object
Builder for a command-line option.
The builder guarantees the option it builds is valid.
At a minimum an option requires a name.
  • Method Details

    • name

      public CmdArgOption.Builder<T> name(String _name)
      Sets option long name.
      Parameters:
      _name - name
      Returns:
      this
    • shortName

      public CmdArgOption.Builder<T> shortName(Character _name)
      Sets option short name.
      Parameters:
      _name - name
      Returns:
      this
    • required

      public CmdArgOption.Builder<T> required(boolean _required)
      Sets option to be required or optional.
      Parameters:
      _required - true to be required
      Returns:
      this
    • required

      public CmdArgOption.Builder<T> required()
      Sets option to be required.
      Returns:
      this
    • optional

      public CmdArgOption.Builder<T> optional()
      Sets option to be optional.
      Returns:
      this
    • repeatable

      public CmdArgOption.Builder<T> repeatable(boolean _repeatable)
      Sets option to be repeatable (true) or not (false).
      Parameters:
      _repeatable - true to be repeatable
      Returns:
      this
    • repeatable

      public CmdArgOption.Builder<T> repeatable()
      Sets option to be repeatable.
      Returns:
      this
    • defaultValue

      public CmdArgOption.Builder<T> defaultValue(T _defaultValue)
      Sets the option's default value.
      Parameters:
      _defaultValue - value to use, never null
      Returns:
      this
    • description

      public CmdArgOption.Builder<T> description(String _description)
      Sets the option's description text.
      Parameters:
      _description - text to use
      Returns:
      this
    • build

      public CmdArgOption<T> build()
      Create the option object based on configuration.
      Returns:
      CmdArgOption