java.lang.Object
org.refcodes.cli.CliSugar
Declarative syntactic sugar which may be statically imported in order to
allow declarative definitions for the command line
Flag
,
ArgsSyntax
, Option
and Operand
elements.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ArgsSyntax
all
(Syntaxable aArg) static ArgsSyntax
and
(Syntaxable... aArgs) static ArgsSyntax
any
(Syntaxable... aArgs) static <T> ArrayOperand<T>
Creates an array representation facade for the encapsulatedOperand
.static <T> ArrayOperand<T>
Creates an array representation facade for the encapsulatedOperand
.static <T> ArrayOperand<T>
Creates an array representation facade for the encapsulatedOperand
.static <T> ArrayOption<T>
Creates an array representation facade for the encapsulatedOption
.static <T> ArrayOption<T>
Creates an array representation facade for the encapsulatedOption
.static <T> ArrayOption<T>
Creates an array representation facade for the encapsulatedOption
.static ArgsSyntax
cases
(Syntaxable... aArgs) static CharOption
charOption
(String aLongOption, String aAlias, String aDescription) Character option.static CharOption
charOption
(String aShortOption, String aLongOption, String aAlias, String aDescription) Character option.static CleanFlag
Constructs the predefined cleanFlag
.static CleanFlag
cleanFlag
(boolean hasShortOption) Constructs the predefined cleanFlag
.static CleanFlag
Constructs the predefined cleanFlag
.static ConfigOption
Creates aConfigOption
representing value specifying a configuration resource (file).static ConfigOption
configOption
(String aDescription) Creates aConfigOption
representing a value specifying a configuration resource (file).static DaemonFlag
Constructs the predefined daemonFlag
.static DaemonFlag
daemonFlag
(boolean hasShortOption) Constructs the predefined daemonFlag
.static DaemonFlag
daemonFlag
(String aDescription) Constructs the predefined daemonFlag
.static DebugFlag
Constructs the predefined debugFlag
.static DebugFlag
debugFlag
(boolean hasShortOption) Constructs the predefined debugFlag
.static DebugFlag
Constructs the predefined debugFlag
.static DoubleOption
doubleOption
(String aLongOption, String aAlias, String aDescription) Double option.static DoubleOption
doubleOption
(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 Example
static Example[]
Sugar for creating anExample
array from a varargs argument.static FileOption
fileOption
(String aLongOption, String aAlias, String aDescription) Creates aFileOption
for getting aFile
instance from a path.static FileOption
fileOption
(String aShortOption, String aLongOption, String aAlias, String aDescription) Creates aFileOption
for getting aFile
instance from a path.static Flag
As "switch" is a reserved word in Java, we use "flag" :-(.static Flag
As "switch" is a reserved word in Java, we use "flag" :-(.static FloatOption
floatOption
(String aLongOption, String aAlias, String aDescription) Float option.static FloatOption
floatOption
(String aShortOption, String aLongOption, String aAlias, String aDescription) Float option.static ForceFlag
Constructs the predefined forceFlag
.static ForceFlag
forceFlag
(boolean hasShortOption) Constructs the predefined forceFlag
.static ForceFlag
Constructs the predefined forceFlag
.static HelpFlag
helpFlag()
Constructs the predefined helpFlag
.static HelpFlag
helpFlag
(boolean hasShortOption) Constructs the predefined helpFlag
.static HelpFlag
Constructs the predefined helpFlag
.static InitFlag
initFlag()
Constructs the predefined initFlag
.static InitFlag
initFlag
(boolean hasShortOption) Constructs the predefined initFlag
.static InitFlag
Constructs the predefined initFlag
.static IntOption
Int option.static IntOption
Int option.static LongOption
longOption
(String aLongOption, String aAlias, String aDescription) Long option.static LongOption
longOption
(String aShortOption, String aLongOption, String aAlias, String aDescription) Long option.static NoneOperand
Instantiates a newNoneOperand
.static NoneOperand
Instantiates a newNoneOperand
.static NoneOperand
Instantiates a newNoneOperand
.static Operation
Constructs aOperation
with the given arguments.static Operation
Constructs aOperation
with the given arguments.static ArgsSyntax
optional
(Syntaxable... aArgs) Semantically identical synonym for theoptional(Syntaxable...)
declaration.static ArgsSyntax
or
(Syntaxable... aArgs) static QuietFlag
Constructs the predefined quietFlag
.static QuietFlag
quietFlag
(boolean hasShortOption) Constructs the predefined quietFlag
.static QuietFlag
Constructs the predefined quietFlag
.static StringOperand
stringOperand
(String aIdentifier, String aDescription) String operand.static StringOption
stringOption
(String aLongOption, String aAlias, String aDescription) String option.static StringOption
stringOption
(String aShortOption, String aLongOption, String aAlias, String aDescription) String option.static SysInfoFlag
Constructs the predefined system infoFlag
.static SysInfoFlag
sysInfoFlag
(boolean hasShortOption) Constructs the predefined system infoFlag
.static SysInfoFlag
sysInfoFlag
(String aDescription) Constructs the predefined system infoFlag
.static VerboseFlag
Constructs the predefined verboseFlag
.static VerboseFlag
verboseFlag
(boolean hasShortOption) Constructs the predefined verboseFlag
.static VerboseFlag
verboseFlag
(String aDescription) Constructs the predefined verboseFlag
.static ArgsSyntax
xor
(Syntaxable... aArgs)
-
Constructor Details
-
CliSugar
public CliSugar()
-
-
Method Details
-
examples
Sugar for creating anExample
array from a varargs argument.- Parameters:
aExamples
- theExample
varargs argument.- Returns:
- The according array representation.
-
example
-
operation
Constructs aOperation
with the given arguments.- Parameters:
aOperation
- The operation to declare.aDescription
- A description without any line breaks.- Returns:
- The accordingly created
Operation
.
-
operation
Constructs aOperation
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
- Parameters:
aArgs
- TheSyntaxable
(ArgsSyntax
) instances to be nested.- Returns:
- The according AND condition.
- See Also:
-
all
- Parameters:
aArg
- TheSyntaxable
(ArgsSyntax
) instance to be nested.- Returns:
- The according ALL condition.
- See Also:
-
or
- Parameters:
aArgs
- TheSyntaxable
(ArgsSyntax
) instances to be nested.- Returns:
- The according OR condition.
- See Also:
-
xor
- Parameters:
aArgs
- TheSyntaxable
(ArgsSyntax
) instances to be nested.- Returns:
- The according XOR condition.
- See Also:
-
cases
- Parameters:
aArgs
- TheSyntaxable
(ArgsSyntax
) instances to be nested.- Returns:
- The according CasesCondition (https://www.metacodes.pro XOR) condition.
- See Also:
-
any
Instantiates a newAnyCondition
with theSyntaxable
(ArgsSyntax
) instances to be nested. Any of the nestedArgsSyntax
conditions may match for theAnyCondition
to match, e.g. all of the nested conditions are optional.- Parameters:
aArgs
- TheSyntaxable
(ArgsSyntax
) instances to be nested- Returns:
- The according
AbstractCondition
. - See Also:
-
optional
Semantically identical synonym for theoptional(Syntaxable...)
declaration.- Parameters:
aArgs
- TheSyntaxable
(ArgsSyntax
) instances to be nested- Returns:
- The according
AbstractCondition
. - See Also:
-
none
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:
-
none
Instantiates a newNoneOperand
.- Parameters:
aDescription
- A description without any line breaks.- Returns:
- the none operand
- See Also:
-
none
Instantiates a newNoneOperand
.- Parameters:
aProperty
- The key (= alias) and the value for the operand.- Returns:
- the none operand
- See Also:
-
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
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:
-
flag
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
Constructs the predefined daemonFlag
.- Parameters:
aDescription
- The description to use when printing out the help text.- Returns:
- The according
Flag
. - See Also:
-
daemonFlag
Constructs the predefined daemonFlag
.- Returns:
- The according
Flag
. - See Also:
-
daemonFlag
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:
-
forceFlag
Constructs the predefined forceFlag
. -
forceFlag
Constructs the predefined forceFlag
. -
forceFlag
Constructs the predefined forceFlag
. -
helpFlag
Constructs the predefined helpFlag
. -
helpFlag
Constructs the predefined helpFlag
. -
helpFlag
Constructs the predefined helpFlag
. -
initFlag
Constructs the predefined initFlag
. -
initFlag
Constructs the predefined initFlag
. -
initFlag
Constructs the predefined initFlag
. -
cleanFlag
Constructs the predefined cleanFlag
. -
cleanFlag
Constructs the predefined cleanFlag
. -
cleanFlag
Constructs the predefined cleanFlag
. -
sysInfoFlag
Constructs the predefined system infoFlag
.- Parameters:
aDescription
- The description to use when printing out the help text.- Returns:
- The according
Flag
. - See Also:
-
sysInfoFlag
Constructs the predefined system infoFlag
.- Returns:
- The according
Flag
. - See Also:
-
sysInfoFlag
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:
-
quietFlag
Constructs the predefined quietFlag
. -
quietFlag
Constructs the predefined quietFlag
. -
quietFlag
Constructs the predefined quietFlag
. -
verboseFlag
Constructs the predefined verboseFlag
.- Parameters:
aDescription
- The description to use when printing out the help text.- Returns:
- The according
Flag
. - See Also:
-
verboseFlag
Constructs the predefined verboseFlag
.- Returns:
- The according
Flag
. - See Also:
-
verboseFlag
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:
-
debugFlag
Constructs the predefined debugFlag
. -
debugFlag
Constructs the predefined debugFlag
. -
debugFlag
Constructs the predefined debugFlag
. -
intOption
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
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:
-
longOption
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
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:
-
floatOption
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:
-
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:
-
doubleOption
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:
-
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:
-
stringOption
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
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:
-
charOption
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:
-
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:
-
configOption
Creates aConfigOption
representing value specifying a configuration resource (file).- Returns:
- the according
ConfigOption
. - See Also:
-
configOption
Creates aConfigOption
representing 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:
-
fileOption
Creates aFileOption
for getting aFile
instance 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
public static FileOption fileOption(String aShortOption, String aLongOption, String aAlias, String aDescription) Creates aFileOption
for getting aFile
instance 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:
-
stringOperand
String operand.- Parameters:
aIdentifier
- the identifieraDescription
- The description to use when printing out the help text.- Returns:
- the operand
- See Also:
-
asArray
Creates an array representation facade for the encapsulatedOption
. This way anyOption
can 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 theOption
for which to create anArrayOption
.- Parameters:
aOption
- TheOption
which's array counterpart is to be defined.- Returns:
- The according
ArrayOption
.
-
asArray
Creates an array representation facade for the encapsulatedOption
. This way anyOption
can 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 theOption
for which to create anArrayOption
.- Parameters:
aOption
- TheOption
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
Creates an array representation facade for the encapsulatedOption
. This way anyOption
can 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 theOption
for which to create anArrayOption
.- Parameters:
aOption
- TheOption
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
Creates an array representation facade for the encapsulatedOperand
. This way anyOperand
can 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 theOperand
for which to create anArrayOperand
.- Parameters:
aOperand
- TheOperand
which's array counterpart is to be defined.- Returns:
- The according
ArrayOperand
.
-
asArray
Creates an array representation facade for the encapsulatedOperand
. This way anyOperand
can 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 theOperand
for which to create anArrayOperand
.- Parameters:
aOperand
- TheOperand
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
Creates an array representation facade for the encapsulatedOperand
. This way anyOperand
can 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 theOperand
for which to create anArrayOperand
.- Parameters:
aOperand
- TheOperand
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
.
-