- 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 lineFlag,ArgsSyntax,OptionandOperandelements.
-
-
Constructor Summary
Constructors Constructor Description CliSugar()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ArgsSyntaxall(Syntaxable aArg)static ArgsSyntaxand(Syntaxable... aArgs)static ArgsSyntaxany(Syntaxable... aArgs)static <T> ArrayOperand<T>asArray(Operand<T> aOperand)Creates an array representation facade for the encapsulatedOperand.static <T> ArrayOperand<T>asArray(Operand<T> aOperand, int aLength)Creates an array representation facade for the encapsulatedOperand.static <T> ArrayOperand<T>asArray(Operand<T> aOperand, int aMinLength, int aMaxLength)Creates an array representation facade for the encapsulatedOperand.static <T> ArrayOption<T>asArray(Option<T> aOption)Creates an array representation facade for the encapsulatedOption.static <T> ArrayOption<T>asArray(Option<T> aOption, int aLength)Creates an array representation facade for the encapsulatedOption.static <T> ArrayOption<T>asArray(Option<T> aOption, int aMinLength, int aMaxLength)Creates an array representation facade for the encapsulatedOption.static ArgsSyntaxcases(Syntaxable... aArgs)static CharOptioncharOption(String aLongOption, String aAlias, String aDescription)Character option.static CharOptioncharOption(String aShortOption, String aLongOption, String aAlias, String aDescription)Character option.static CleanFlagcleanFlag()Constructs the predefined cleanFlag.static CleanFlagcleanFlag(boolean hasShortOption)Constructs the predefined cleanFlag.static CleanFlagcleanFlag(String aDescription)Constructs the predefined cleanFlag.static ConfigOptionconfigOption()Creates aConfigOptionrepresenting value specifying a configuration resource (file).static ConfigOptionconfigOption(String aDescription)Creates aConfigOptionrepresenting a value specifying a configuration resource (file).static DaemonFlagdaemonFlag()Constructs the predefined daemonFlag.static DaemonFlagdaemonFlag(boolean hasShortOption)Constructs the predefined daemonFlag.static DaemonFlagdaemonFlag(String aDescription)Constructs the predefined daemonFlag.static DebugFlagdebugFlag()Constructs the predefined debugFlag.static DebugFlagdebugFlag(boolean hasShortOption)Constructs the predefined debugFlag.static DebugFlagdebugFlag(String aDescription)Constructs the predefined debugFlag.static DoubleOptiondoubleOption(String aLongOption, String aAlias, String aDescription)Double option.static DoubleOptiondoubleOption(String aShortOption, String aLongOption, String aAlias, String aDescription)Double option.static <T extends Enum<T>>
EnumOption<T>enumOption(String aLongOption, Class<T> aType, String aAlias, String aDescription)Instantiates a new enum option.static <T extends Enum<T>>
EnumOption<T>enumOption(String aShortOption, String aLongOption, Class<T> aType, String aAlias, String aDescription)Instantiates a new enum option.static Exampleexample(String aDescription, Operand<?>... aOperands)static Example[]examples(Example... aExamples)Sugar for creating anExamplearray from a varargs argument.static FileOptionfileOption(String aLongOption, String aAlias, String aDescription)Creates aFileOptionfor getting aFileinstance from a path.static FileOptionfileOption(String aShortOption, String aLongOption, String aAlias, String aDescription)Creates aFileOptionfor getting aFileinstance from a path.static Flagflag(String aLongOption, String aAlias, String aDescription)As "switch" is a reserved word in Java, we use "flag" :-(.static Flagflag(String aShortOption, String aLongOption, String aAlias, String aDescription)As "switch" is a reserved word in Java, we use "flag" :-(.static FloatOptionfloatOption(String aLongOption, String aAlias, String aDescription)Float option.static FloatOptionfloatOption(String aShortOption, String aLongOption, String aAlias, String aDescription)Float option.static ForceFlagforceFlag()Constructs the predefined forceFlag.static ForceFlagforceFlag(boolean hasShortOption)Constructs the predefined forceFlag.static ForceFlagforceFlag(String aDescription)Constructs the predefined forceFlag.static HelpFlaghelpFlag()Constructs the predefined helpFlag.static HelpFlaghelpFlag(boolean hasShortOption)Constructs the predefined helpFlag.static HelpFlaghelpFlag(String aDescription)Constructs the predefined helpFlag.static InitFlaginitFlag()Constructs the predefined initFlag.static InitFlaginitFlag(boolean hasShortOption)Constructs the predefined initFlag.static InitFlaginitFlag(String aDescription)Constructs the predefined initFlag.static IntOptionintOption(String aLongOption, String aAlias, String aDescription)Int option.static IntOptionintOption(String aShortOption, String aLongOption, String aAlias, String aDescription)Int option.static LongOptionlongOption(String aLongOption, String aAlias, String aDescription)Long option.static LongOptionlongOption(String aShortOption, String aLongOption, String aAlias, String aDescription)Long option.static NoneOperandnone(String aDescription)Instantiates a newNoneOperand.static NoneOperandnone(String aAlias, String aDescription)Instantiates a newNoneOperand.static NoneOperandnone(org.refcodes.struct.Relation<String,Boolean> aProperty)Instantiates a newNoneOperand.static Operationoperation(String aOperation, String aDescription)Constructs aOperationwith the given arguments.static Operationoperation(String aOperation, String aAlias, String aDescription)Constructs aOperationwith the given arguments.static ArgsSyntaxoptional(Syntaxable... aArgs)Semantically identical synonym for theoptional(Syntaxable...)declaration.static ArgsSyntaxor(Syntaxable... aArgs)static QuietFlagquietFlag()Constructs the predefined quietFlag.static QuietFlagquietFlag(boolean hasShortOption)Constructs the predefined quietFlag.static QuietFlagquietFlag(String aDescription)Constructs the predefined quietFlag.static StringOperandstringOperand(String aIdentifier, String aDescription)String operand.static StringOptionstringOption(String aLongOption, String aAlias, String aDescription)String option.static StringOptionstringOption(String aShortOption, String aLongOption, String aAlias, String aDescription)String option.static SysInfoFlagsysInfoFlag()Constructs the predefined system infoFlag.static SysInfoFlagsysInfoFlag(boolean hasShortOption)Constructs the predefined system infoFlag.static SysInfoFlagsysInfoFlag(String aDescription)Constructs the predefined system infoFlag.static VerboseFlagverboseFlag()Constructs the predefined verboseFlag.static VerboseFlagverboseFlag(boolean hasShortOption)Constructs the predefined verboseFlag.static VerboseFlagverboseFlag(String aDescription)Constructs the predefined verboseFlag.static ArgsSyntaxxor(Syntaxable... aArgs)
-
-
-
Method Detail
-
examples
public static Example[] examples(Example... aExamples)
Sugar for creating anExamplearray from a varargs argument.- Parameters:
aExamples- theExamplevarargs argument.- Returns:
- The according array representation.
-
operation
public static Operation operation(String aOperation, String aDescription)
Constructs aOperationwith 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 aOperationwith 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 ArgsSyntax and(Syntaxable... aArgs)
- Parameters:
aArgs- TheSyntaxable(ArgsSyntax) instances to be nested.- Returns:
- The according AND condition.
- See Also:
AndCondition
-
all
public static ArgsSyntax all(Syntaxable aArg)
- Parameters:
aArg- TheSyntaxable(ArgsSyntax) instance to be nested.- Returns:
- The according ALL condition.
- See Also:
AllCondition
-
or
public static ArgsSyntax or(Syntaxable... aArgs)
- Parameters:
aArgs- TheSyntaxable(ArgsSyntax) instances to be nested.- Returns:
- The according OR condition.
- See Also:
OrCondition
-
xor
public static ArgsSyntax xor(Syntaxable... aArgs)
- Parameters:
aArgs- TheSyntaxable(ArgsSyntax) instances to be nested.- Returns:
- The according XOR condition.
- See Also:
XorCondition
-
cases
public static ArgsSyntax cases(Syntaxable... aArgs)
- Parameters:
aArgs- TheSyntaxable(ArgsSyntax) instances to be nested.- Returns:
- The according CasesCondition (special XOR) condition.
- See Also:
CasesCondition
-
any
public static ArgsSyntax any(Syntaxable... aArgs)
Instantiates a newAnyConditionwith theSyntaxable(ArgsSyntax) instances to be nested. Any of the nestedArgsSyntaxconditions may match for theAnyConditionto match, e.g. all of the nested conditions are optional.- Parameters:
aArgs- TheSyntaxable(ArgsSyntax) instances to be nested- Returns:
- The according
AbstractCondition. - See Also:
AnyCondition
-
optional
public static ArgsSyntax optional(Syntaxable... aArgs)
Semantically identical synonym for theoptional(Syntaxable...)declaration.- Parameters:
aArgs- TheSyntaxable(ArgsSyntax) instances to be nested- Returns:
- The according
AbstractCondition. - See Also:
AnyCondition
-
none
public static NoneOperand none(String aAlias, String aDescription)
Instantiates a newNoneOperand.- Parameters:
aAlias- The identifier to be used when printing the syntax via theSyntaxable.toSyntax(SyntaxNotation, String, String, String)method.aDescription- A description without any line breaks.- Returns:
- the none operand
- See Also:
NoneOperand
-
none
public static NoneOperand none(String aDescription)
Instantiates a newNoneOperand.- Parameters:
aDescription- A description without any line breaks.- Returns:
- the none operand
- See Also:
NoneOperand
-
none
public static NoneOperand none(org.refcodes.struct.Relation<String,Boolean> aProperty)
Instantiates a newNoneOperand.- Parameters:
aProperty- The key (= alias) and the value for the operand.- Returns:
- the none operand
- See Also:
NoneOperand
-
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 optionaLongOption- the long optionaType- the typeaAlias- the option arg nameaDescription- The description to use when printing out the help text.- 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 optionaType- the typeaAlias- the option arg nameaDescription- The description to use when printing out the help text.- 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" :-(.
-
flag
public static Flag flag(String aShortOption, String aLongOption, String aAlias, String aDescription)
As "switch" is a reserved word in Java, we use "flag" :-(.
-
daemonFlag
public static DaemonFlag daemonFlag(String aDescription)
Constructs the predefined daemonFlag.- Parameters:
aDescription- The description to use when printing out the help text.- Returns:
- The according
Flag. - See Also:
DaemonFlag
-
daemonFlag
public static DaemonFlag daemonFlag()
Constructs the predefined daemonFlag.- Returns:
- The according
Flag. - See Also:
DaemonFlag
-
daemonFlag
public static DaemonFlag daemonFlag(boolean hasShortOption)
Constructs the predefined daemonFlag.- Parameters:
hasShortOption- True in case to also enable the short option, else only the long option takes effect.- Returns:
- The according
Flag. - See Also:
DaemonFlag
-
forceFlag
public static ForceFlag forceFlag(String aDescription)
Constructs the predefined forceFlag.
-
forceFlag
public static ForceFlag forceFlag(boolean hasShortOption)
Constructs the predefined forceFlag.
-
helpFlag
public static HelpFlag helpFlag(boolean hasShortOption)
Constructs the predefined helpFlag.
-
initFlag
public static InitFlag initFlag(boolean hasShortOption)
Constructs the predefined initFlag.
-
cleanFlag
public static CleanFlag cleanFlag(String aDescription)
Constructs the predefined cleanFlag.
-
cleanFlag
public static CleanFlag cleanFlag(boolean hasShortOption)
Constructs the predefined cleanFlag.
-
sysInfoFlag
public static SysInfoFlag sysInfoFlag(String aDescription)
Constructs the predefined system infoFlag.- Parameters:
aDescription- The description to use when printing out the help text.- Returns:
- The according
Flag. - See Also:
SysInfoFlag
-
sysInfoFlag
public static SysInfoFlag sysInfoFlag()
Constructs the predefined system infoFlag.- Returns:
- The according
Flag. - See Also:
SysInfoFlag
-
sysInfoFlag
public static SysInfoFlag sysInfoFlag(boolean hasShortOption)
Constructs the predefined system infoFlag.- Parameters:
hasShortOption- True in case to also enable the short option, else only the long option takes effect.- Returns:
- The according
Flag. - See Also:
SysInfoFlag
-
quietFlag
public static QuietFlag quietFlag(String aDescription)
Constructs the predefined quietFlag.
-
quietFlag
public static QuietFlag quietFlag(boolean hasShortOption)
Constructs the predefined quietFlag.
-
verboseFlag
public static VerboseFlag verboseFlag(String aDescription)
Constructs the predefined verboseFlag.- Parameters:
aDescription- The description to use when printing out the help text.- Returns:
- The according
Flag. - See Also:
VerboseFlag
-
verboseFlag
public static VerboseFlag verboseFlag()
Constructs the predefined verboseFlag.- Returns:
- The according
Flag. - See Also:
VerboseFlag
-
verboseFlag
public static VerboseFlag verboseFlag(boolean hasShortOption)
Constructs the predefined verboseFlag.- Parameters:
hasShortOption- True in case to also enable the short option, else only the long option takes effect.- Returns:
- The according
Flag. - See Also:
VerboseFlag
-
debugFlag
public static DebugFlag debugFlag(String aDescription)
Constructs the predefined debugFlag.
-
debugFlag
public static DebugFlag debugFlag(boolean hasShortOption)
Constructs the predefined debugFlag.
-
intOption
public static IntOption intOption(String aLongOption, String aAlias, String aDescription)
Int option.- Parameters:
aLongOption- the long optionaAlias- the option arg nameaDescription- The description to use when printing out the help text.- 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 optionaLongOption- the long optionaAlias- the option arg nameaDescription- The description to use when printing out the help text.- Returns:
- the option
- See Also:
IntOption
-
longOption
public static LongOption longOption(String aLongOption, String aAlias, String aDescription)
Long option.- Parameters:
aLongOption- the long optionaAlias- the option arg nameaDescription- The description to use when printing out the help text.- 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 optionaLongOption- the long optionaAlias- the option arg nameaDescription- The description to use when printing out the help text.- Returns:
- the option
- See Also:
LongOption
-
floatOption
public static FloatOption floatOption(String aLongOption, String aAlias, String aDescription)
Float option.- Parameters:
aLongOption- the long optionaAlias- the option arg nameaDescription- The description to use when printing out the help text.- 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 optionaLongOption- the long optionaAlias- the option arg nameaDescription- The description to use when printing out the help text.- Returns:
- the option
- See Also:
LongOption
-
doubleOption
public static DoubleOption doubleOption(String aLongOption, String aAlias, String aDescription)
Double option.- Parameters:
aLongOption- the long optionaAlias- the option arg nameaDescription- The description to use when printing out the help text.- 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 optionaLongOption- the long optionaAlias- the option arg nameaDescription- The description to use when printing out the help text.- Returns:
- the option
- See Also:
LongOption
-
stringOption
public static StringOption stringOption(String aLongOption, String aAlias, String aDescription)
String option.- Parameters:
aLongOption- the long optionaAlias- the option arg nameaDescription- The description to use when printing out the help text.- 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 optionaLongOption- the long optionaAlias- the option arg nameaDescription- The description to use when printing out the help text.- Returns:
- the option
- See Also:
StringOption
-
charOption
public static CharOption charOption(String aLongOption, String aAlias, String aDescription)
Character option.- Parameters:
aLongOption- the long optionaAlias- the option arg nameaDescription- The description to use when printing out the help text.- 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 optionaLongOption- the long optionaAlias- the option arg nameaDescription- The description to use when printing out the help text.- Returns:
- the option
- See Also:
StringOption
-
configOption
public static ConfigOption configOption()
Creates aConfigOptionrepresenting value specifying a configuration resource (file).- Returns:
- the according
ConfigOption. - See Also:
ConfigOption
-
configOption
public static ConfigOption configOption(String aDescription)
Creates aConfigOptionrepresenting a value specifying a configuration resource (file).- Parameters:
aDescription- The description to use when printing out the help text. to use when printing out the help text.- Returns:
- the according
ConfigOption. - See Also:
ConfigOption
-
fileOption
public static FileOption fileOption(String aLongOption, String aAlias, String aDescription)
Creates aFileOptionfor getting aFileinstance from a path.- Parameters:
aLongOption- the long optionaAlias- the option arg nameaDescription- The description to use when printing out the help text.- Returns:
- the option
- See Also:
FileOption
-
fileOption
public static FileOption fileOption(String aShortOption, String aLongOption, String aAlias, String aDescription)
Creates aFileOptionfor getting aFileinstance from a path.- Parameters:
aShortOption- the short optionaLongOption- the long optionaAlias- the option arg nameaDescription- The description to use when printing out the help text.- Returns:
- the option
- See Also:
FileOption
-
stringOperand
public static StringOperand stringOperand(String aIdentifier, String aDescription)
String operand.- Parameters:
aIdentifier- the identifieraDescription- The description to use when printing out the help text.- Returns:
- the operand
- See Also:
StringOperand
-
asArray
public static <T> ArrayOption<T> asArray(Option<T> aOption)
Creates an array representation facade for the encapsulatedOption. This way anyOptioncan also be used as an arrayOption, e.g. it can be provided multiple times in the command line arguments.- Type Parameters:
T- The type of theOptionfor which to create anArrayOption.- Parameters:
aOption- TheOptionwhich'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 encapsulatedOption. This way anyOptioncan also be used as an arrayOption, e.g. it can by provided multiple times in the command line arguments.- Type Parameters:
T- The type of theOptionfor which to create anArrayOption.- Parameters:
aOption- TheOptionwhich'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 encapsulatedOption. This way anyOptioncan also be used as an arrayOption, e.g. it can by provided multiple times in the command line arguments.- Type Parameters:
T- The type of theOptionfor which to create anArrayOption.- Parameters:
aOption- TheOptionwhich'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 encapsulatedOperand. This way anyOperandcan also be used as an arrayOperand, e.g. it can be provided multiple times in the command line arguments.- Type Parameters:
T- The type of theOperandfor which to create anArrayOperand.- Parameters:
aOperand- TheOperandwhich'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 encapsulatedOperand. This way anyOperandcan also be used as an arrayOperand, e.g. it can by provided multiple times in the command line arguments.- Type Parameters:
T- The type of theOperandfor which to create anArrayOperand.- Parameters:
aOperand- TheOperandwhich'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 encapsulatedOperand. This way anyOperandcan also be used as an arrayOperand, e.g. it can by provided multiple times in the command line arguments.- Type Parameters:
T- The type of theOperandfor which to create anArrayOperand.- Parameters:
aOperand- TheOperandwhich'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.
-
-