Package readycli

Class Option

java.lang.Object
readycli.Option
All Implemented Interfaces:
java.io.Serializable

public final class Option
extends java.lang.Object
implements java.io.Serializable
An option is an argument of a Command that can be optionally specified on command.line. An option is useful to change the default values of some parameters. These parameters, if present, succeed the option name on the command-line. An option with no parameters is called a flag. To create a new option, the create(String, String) method must be invoked.
Author:
Salvatore Giampa'
See Also:
Serialized Form
  • Nested Class Summary

    Nested Classes 
    Modifier and Type Class Description
    static class  Option.Builder
    A builder entity used build new options.
    static class  Option.Parameter
    Represents a parameter of an Option.
  • Method Summary

    Modifier and Type Method Description
    static Option.Builder create​(java.lang.String name, java.lang.String description)
    Starts the creation of a new command-line option.
    java.util.List<java.lang.String> getAliases()
    Gets the list of the aliases of this option. the aliases are secondary or shortest names assigned to an option, to simplify its specification on command-line.
    java.lang.String getDescription()
    Gets the description of the option.
    java.lang.String getName()
    Gets the name of the option.
    java.util.List<Option.Parameter> getParameters()
    Gets the list of the option parameters, in the order they were specified during construction.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getName

      public java.lang.String getName()
      Gets the name of the option.
      Returns:
      the name of the option as a string
    • getDescription

      public java.lang.String getDescription()
      Gets the description of the option.
      Returns:
      the description of the option as a string
    • getParameters

      public java.util.List<Option.Parameter> getParameters()
      Gets the list of the option parameters, in the order they were specified during construction.
      Returns:
      the list of parameters.
    • getAliases

      public java.util.List<java.lang.String> getAliases()
      Gets the list of the aliases of this option. the aliases are secondary or shortest names assigned to an option, to simplify its specification on command-line.
      Returns:
      the list of aliases assigned to this option
    • create

      public static Option.Builder create​(java.lang.String name, java.lang.String description)
      Starts the creation of a new command-line option. An option can be specified on the command-line by specifying its name preceded by two consecutive minus ("--") characters.

      An option can be accessed from the CommandContext only through its name as it is specified during the construction of the option.
      Parameters:
      name - the name of the option
      description - the description of the option
      Returns:
      An Option.Builder object