Class CliSugar

java.lang.Object
org.refcodes.cli.CliSugar

public class CliSugar
extends Object
Declarative syntactic sugar which may be statically imported in order to allow declarative definitions for the command line Flag, Condition, Option and Operand elements.
  • Constructor Details

    • CliSugar

      public CliSugar()
  • Method Details

    • operation

      public static Operation operation​(String aOperation, String aDescription)
      Constructs a Operation with the given arguments.
      Parameters:
      aOperation - The operation to declare.
      aDescription - A description without any line breaks.
      Returns:
      The accordingly created Operation.
    • operation

      public static Operation operation​(String aOperation, String aAlias, String aDescription)
      Constructs a Operation with the given arguments.
      Parameters:
      aOperation - The operation to declare.
      aAlias - The operation's name to be used when constructing the syntax.
      aDescription - A description without any line breaks.
      Returns:
      The accordingly created Operation.
    • and

      public static Condition and​(Syntaxable... aArgs)
      Instantiates a new AndCondition with the Syntaxable (Condition) instances to be nested.
      Parameters:
      aArgs - The Syntaxable (Condition) instances to be nested.
      Returns:
      The according AND condition.
      See Also:
      AndCondition
    • or

      public static Condition or​(Syntaxable... aArgs)
      Instantiates a new OrCondition with the Syntaxable (Condition) instances to be nested.
      Parameters:
      aArgs - The Syntaxable (Condition) instances to be nested.
      Returns:
      The according OR condition.
      See Also:
      OrCondition
    • xor

      public static Condition xor​(Syntaxable... aArgs)
      Instantiates a new XorCondition with the Syntaxable (Condition) instances to be nested.
      Parameters:
      aArgs - The Syntaxable (Condition) instances to be nested.
      Returns:
      The according XOR condition.
      See Also:
      XorCondition
    • optional

      public static Condition optional​(Syntaxable... aArgs)
      * Instantiates a new OptionalCondition with the Syntaxable (Condition) instances to be nested.
      Parameters:
      aArgs - The Syntaxable (Condition) instances to be nested
      Returns:
      the condition
      See Also:
      OptionalCondition
    • enumOption

      public static <T extends Enum<T>> EnumOption<T> enumOption​(String aShortOption, String aLongOption, Class<T> aType, String aAlias, String aDescription)
      Instantiates a new enum option.
      Type Parameters:
      T - the generic type
      Parameters:
      aShortOption - the short option
      aLongOption - the long option
      aType - the type
      aAlias - the option arg name
      aDescription - the description
      Returns:
      the option
      See Also:
      EnumOption
    • enumOption

      public static <T extends Enum<T>> EnumOption<T> enumOption​(String aLongOption, Class<T> aType, String aAlias, String aDescription)
      Instantiates a new enum option.
      Type Parameters:
      T - the generic type
      Parameters:
      aLongOption - the long option
      aType - the type
      aAlias - the option arg name
      aDescription - the description
      Returns:
      the option
      See Also:
      EnumOption
    • flag

      public static Flag flag​(String aLongOption, String aAlias, String aDescription)
      As "switch" is a reserved word in Java, we use "flag" :-(.
      Parameters:
      aLongOption - the long option
      aAlias - The alias of the flag
      aDescription - the description
      Returns:
      the flag
      See Also:
      Flag
    • flag

      public static Flag flag​(String aShortOption, String aLongOption, String aAlias, String aDescription)
      As "switch" is a reserved word in Java, we use "flag" :-(.
      Parameters:
      aShortOption - the short option
      aLongOption - the long option
      aAlias - The alias of the flag
      aDescription - the description
      Returns:
      the flag
      See Also:
      Flag
    • forcesFlag

      public static Flag forcesFlag​(String aDescription)
      Forces flag.
      Parameters:
      aDescription - the description
      Returns:
      the flag
      See Also:
      ForceFlag
    • forcesFlag

      public static Flag forcesFlag()
      Forces flag.
      Returns:
      the flag
      See Also:
      ForceFlag
    • helpFlag

      public static Flag helpFlag​(String aDescription)
      Help flag.
      Parameters:
      aDescription - the description
      Returns:
      the flag
      See Also:
      HelpFlag
    • helpFlag

      public static Flag helpFlag()
      Help flag.
      Returns:
      the flag
      See Also:
      HelpFlag
    • sysInfoFlag

      public static Flag sysInfoFlag​(String aDescription)
      Sys info flag.
      Parameters:
      aDescription - the description
      Returns:
      the flag
      See Also:
      SysInfoFlag
    • sysInfoFlag

      public static Flag sysInfoFlag()
      Sys info flag.
      Returns:
      the flag
      See Also:
      SysInfoFlag
    • quietFlag

      public static Flag quietFlag​(String aDescription)
      Quiet flag.
      Parameters:
      aDescription - the description
      Returns:
      the flag
      See Also:
      QuietFlag
    • quietFlag

      public static Flag quietFlag()
      Quiet flag.
      Returns:
      the flag
      See Also:
      QuietFlag
    • verboseFlag

      public static Flag verboseFlag​(String aDescription)
      Verbose flag.
      Parameters:
      aDescription - the description
      Returns:
      the flag
      See Also:
      VerboseFlag
    • verboseFlag

      public static Flag verboseFlag()
      Verbose flag.
      Returns:
      the flag
      See Also:
      VerboseFlag
    • verboseDebug

      public static Flag verboseDebug​(String aDescription)
      Debug flag.
      Parameters:
      aDescription - the description
      Returns:
      the flag
      See Also:
      DebugFlag
    • debugFlag

      public static Flag debugFlag()
      Debug flag.
      Returns:
      the flag
      See Also:
      VerboseFlag
    • intOption

      public static IntOption intOption​(String aLongOption, String aAlias, String aDescription)
      Int option.
      Parameters:
      aLongOption - the long option
      aAlias - the option arg name
      aDescription - the description
      Returns:
      the option
      See Also:
      IntOption
    • intOption

      public static IntOption intOption​(String aShortOption, String aLongOption, String aAlias, String aDescription)
      Int option.
      Parameters:
      aShortOption - the short option
      aLongOption - the long option
      aAlias - the option arg name
      aDescription - the description
      Returns:
      the option
      See Also:
      IntOption
    • longOption

      public static LongOption longOption​(String aLongOption, String aAlias, String aDescription)
      Long option.
      Parameters:
      aLongOption - the long option
      aAlias - the option arg name
      aDescription - the description
      Returns:
      the option
      See Also:
      LongOption
    • longOption

      public static LongOption longOption​(String aShortOption, String aLongOption, String aAlias, String aDescription)
      Long option.
      Parameters:
      aShortOption - the short option
      aLongOption - the long option
      aAlias - the option arg name
      aDescription - the description
      Returns:
      the option
      See Also:
      LongOption
    • floatOption

      public static FloatOption floatOption​(String aLongOption, String aAlias, String aDescription)
      Float option.
      Parameters:
      aLongOption - the long option
      aAlias - the option arg name
      aDescription - the description
      Returns:
      the option
      See Also:
      LongOption
    • floatOption

      public static FloatOption floatOption​(String aShortOption, String aLongOption, String aAlias, String aDescription)
      Float option.
      Parameters:
      aShortOption - the short option
      aLongOption - the long option
      aAlias - the option arg name
      aDescription - the description
      Returns:
      the option
      See Also:
      LongOption
    • doubleOption

      public static DoubleOption doubleOption​(String aLongOption, String aAlias, String aDescription)
      Double option.
      Parameters:
      aLongOption - the long option
      aAlias - the option arg name
      aDescription - the description
      Returns:
      the option
      See Also:
      LongOption
    • doubleOption

      public static DoubleOption doubleOption​(String aShortOption, String aLongOption, String aAlias, String aDescription)
      Double option.
      Parameters:
      aShortOption - the short option
      aLongOption - the long option
      aAlias - the option arg name
      aDescription - the description
      Returns:
      the option
      See Also:
      LongOption
    • stringOption

      public static StringOption stringOption​(String aLongOption, String aAlias, String aDescription)
      String option.
      Parameters:
      aLongOption - the long option
      aAlias - the option arg name
      aDescription - the description
      Returns:
      the option
      See Also:
      StringOption
    • stringOption

      public static StringOption stringOption​(String aShortOption, String aLongOption, String aAlias, String aDescription)
      String option.
      Parameters:
      aShortOption - the short option
      aLongOption - the long option
      aAlias - the option arg name
      aDescription - the description
      Returns:
      the option
      See Also:
      StringOption
    • charOption

      public static CharOption charOption​(String aLongOption, String aAlias, String aDescription)
      Character option.
      Parameters:
      aLongOption - the long option
      aAlias - the option arg name
      aDescription - the description
      Returns:
      the option
      See Also:
      StringOption
    • charOption

      public static CharOption charOption​(String aShortOption, String aLongOption, String aAlias, String aDescription)
      Character option.
      Parameters:
      aShortOption - the short option
      aLongOption - the long option
      aAlias - the option arg name
      aDescription - the description
      Returns:
      the option
      See Also:
      StringOption
    • fileOption

      public static FileOption fileOption​(String aLongOption, String aAlias, String aDescription)
      Creates a FileOption for getting a File instance from a path.
      Parameters:
      aLongOption - the long option
      aAlias - the option arg name
      aDescription - the description
      Returns:
      the option
      See Also:
      FileOption
    • fileOption

      public static FileOption fileOption​(String aShortOption, String aLongOption, String aAlias, String aDescription)
      String option.
      Parameters:
      aShortOption - the short option
      aLongOption - the long option
      aAlias - the option arg name
      aDescription - the description
      Returns:
      the option
      See Also:
      FileOption
    • stringOperand

      public static StringOperand stringOperand​(String aIdentifier, String aDescription)
      String operand.
      Parameters:
      aIdentifier - the identifier
      aDescription - the description
      Returns:
      the operand
      See Also:
      StringOperand
    • asArray

      public static <T> ArrayOption<T> asArray​(Option<T> aOption)
      Creates an array representation facade for the encapsulated Option. This way any Option can also be used as an array Option, e.g. it can be provided multiple times in the command line arguments.
      Type Parameters:
      T - The type of the Option for which to create an ArrayOption.
      Parameters:
      aOption - The Option which's array counterpart is to be defined.
      Returns:
      The according ArrayOption.
    • asArray

      public static <T> ArrayOption<T> asArray​(Option<T> aOption, int aLength)
      Creates an array representation facade for the encapsulated Option. This way any Option can also be used as an array Option, e.g. it can by provided multiple times in the command line arguments.
      Type Parameters:
      T - The type of the Option for which to create an ArrayOption.
      Parameters:
      aOption - The Option which's array counterpart is to be defined.
      aLength - The number of array elements, or -1 if there is no limit.
      Returns:
      The according ArrayOption.
    • asArray

      public static <T> ArrayOption<T> asArray​(Option<T> aOption, int aMinLength, int aMaxLength)
      Creates an array representation facade for the encapsulated Option. This way any Option can also be used as an array Option, e.g. it can by provided multiple times in the command line arguments.
      Type Parameters:
      T - The type of the Option for which to create an ArrayOption.
      Parameters:
      aOption - The Option which's array counterpart is to be defined.
      aMinLength - The minimum number of array elements, or -1 if there is no limit.
      aMaxLength - The maximum number of array elements, or -1 if there is no limit.
      Returns:
      The according ArrayOption.
    • asArray

      public static <T> ArrayOperand<T> asArray​(Operand<T> aOperand)
      Creates an array representation facade for the encapsulated Operand. This way any Operand can also be used as an array Operand, e.g. it can be provided multiple times in the command line arguments.
      Type Parameters:
      T - The type of the Operand for which to create an ArrayOperand.
      Parameters:
      aOperand - The Operand which's array counterpart is to be defined.
      Returns:
      The according ArrayOperand.
    • asArray

      public static <T> ArrayOperand<T> asArray​(Operand<T> aOperand, int aLength)
      Creates an array representation facade for the encapsulated Operand. This way any Operand can also be used as an array Operand, e.g. it can by provided multiple times in the command line arguments.
      Type Parameters:
      T - The type of the Operand for which to create an ArrayOperand.
      Parameters:
      aOperand - The Operand which's array counterpart is to be defined.
      aLength - The number of array elements, or -1 if there is no limit.
      Returns:
      The according ArrayOperand.
    • asArray

      public static <T> ArrayOperand<T> asArray​(Operand<T> aOperand, int aMinLength, int aMaxLength)
      Creates an array representation facade for the encapsulated Operand. This way any Operand can also be used as an array Operand, e.g. it can by provided multiple times in the command line arguments.
      Type Parameters:
      T - The type of the Operand for which to create an ArrayOperand.
      Parameters:
      aOperand - The Operand which's array counterpart is to be defined.
      aMinLength - The minimum number of array elements, or -1 if there is no limit.
      aMaxLength - The maximum number of array elements, or -1 if there is no limit.
      Returns:
      The according ArrayOperand.