public final class CliUtility extends Object
| Modifier and Type | Method | Description |
|---|---|---|
static boolean |
contains(String[] aArgs,
String aArg) |
|
static org.refcodes.struct.Relation<String,String> |
getOptionArgument(Option<?> aOption,
String[] aArgs,
String[] aOptions) |
|
static boolean |
isOptionArgument(String aArg) |
|
static String[] |
toArgs(List<? extends Operand<?>>... aOperands) |
Takes all
Operand instances found in the provided Lists
and adds all therein found argument arrays (as of
Operand.getArgs()) to the result. |
static String[] |
toDiff(String[] aSet,
String[] aSubset) |
Creates the difference between the provided set and the provided subset.
|
static String[] |
toDiff(String[] aSet,
List<? extends Operand<?>> aSubset) |
Creates the difference between the provided set and the provided
Lists therein found argument arrays subset (as of
Operand.getArgs()). |
static String |
toOptionsSpec(Operand<?> aOperand) |
Creates the options specification containing the short option (if any)
and the long option ( if any) from the provided
Operand;. |
static String |
toParameterSpec(Operand<?> aOperand) |
Creates the parameter specification from the provided
Operand. |
static String |
toParameterSpec(Operand<?> aOperand,
int aMin,
int aMax) |
Creates the parameter specification from the provided
Operand. |
static String |
toSpec(Operand<?> aOperand) |
Creates a specification for the given
Operand consisting of the
options specification (if any) as of toOptionsSpec(Operand) and
the parameter specification (if any) as of
toParameterSpec(Operand). |
public static boolean isOptionArgument(String aArg)
String starts with one of the
prefixes Identifying an Option. The prefixes are defined in the
CommandArgPrefix enumeration and are usually the single
hyphen-minus "-" and the double hyphen-minus "--". Usually option
arguments are prefixed either with aaArg - The argument for which to determines whether it represents an
option argument or not.public static org.refcodes.struct.Relation<String,String> getOptionArgument(Option<?> aOption, String[] aArgs, String[] aOptions)
Option's short-option and long-option and tries to
determine that Option's value in the provided command line
arguments. Depending on whether the short-option or the long-option was
detected with a value, the result contains the according option as the
key with the detected value in the Relation instance. Null is
returned when either no option was found or no value for one of the
options.aOption - The option for which to get the valueaArgs - The command line arguments from which to determine the
Option's value.aOptions - The list of options (short and well as long) which are
reserved and cannot be used as value.@SafeVarargs public static String[] toArgs(List<? extends Operand<?>>... aOperands)
Operand instances found in the provided Lists
and adds all therein found argument arrays (as of
Operand.getArgs()) to the result.public static String[] toDiff(String[] aSet, String[] aSubset)
aSet - The set to be used for the diff operation.aSubset - The subset to be used for the diff operation.public static String[] toDiff(String[] aSet, List<? extends Operand<?>> aSubset)
Lists therein found argument arrays subset (as of
Operand.getArgs()).aSet - The set to be used for the diff operation.aSubset - The subset to be used for the diff operation being the
lists containing the Operand instances whose command line
arguments are to be diffed.public static String toParameterSpec(Operand<?> aOperand)
Operand. In
case we got a Flag, then there will be an empty parameter
specification as the Flag implies a parameter. If the
Operand is an option, then the parameter will be prefixed and
suffixed different to an Operand type.aOperand - The operand from which to get the parameter
specification.public static String toParameterSpec(Operand<?> aOperand, int aMin, int aMax)
Operand. In
case we got a Flag, then there will be an empty parameter
specification as the Flag implies a parameter. If the
Operand is an option, then the parameter will be prefixed and
suffixed different to an Operand type.aOperand - The operand from which to get the parameter
specification.aMin - The minimum value for the operand.aMax - The maximum value for the operand.public static String toOptionsSpec(Operand<?> aOperand)
Operand;.aOperand - The operand from which to create the options
specification.String.public static String toSpec(Operand<?> aOperand)
Operand consisting of the
options specification (if any) as of toOptionsSpec(Operand) and
the parameter specification (if any) as of
toParameterSpec(Operand).aOperand - The Operand from which to create the
specification.Copyright © 2021. All rights reserved.