- java.lang.Object
-
- net.sourceforge.argparse4j.impl.Arguments
-
public final class Arguments extends java.lang.Object
This class provides useful shortcuts and constants.
They are mainly used to specify parameter to
Argument
object.
-
-
Field Summary
Fields Modifier and Type Field Description private static AppendArgumentAction
append_
private static AppendConstArgumentAction
appendConst_
private static CountArgumentAction
count_
private static HelpArgumentAction
help_
private static StoreArgumentAction
store_
private static StoreConstArgumentAction
storeConst_
private static StoreFalseArgumentAction
storeFalse_
private static StoreTrueArgumentAction
storeTrue_
static FeatureControl
SUPPRESS
The value ofFeatureControl.SUPPRESS
.private static VersionArgumentAction
version_
-
Constructor Summary
Constructors Modifier Constructor Description private
Arguments()
Intentionally made private to avoid instantiation in application code.
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static AppendArgumentAction
append()
Returns append action.static AppendConstArgumentAction
appendConst()
Returns appendConst action.static BooleanArgumentType
booleanType()
ReturnsBooleanArgumentType
with "true" as true value, and "false" as false value.static BooleanArgumentType
booleanType(java.lang.String trueValue, java.lang.String falseValue)
ReturnsBooleanArgumentType
with given true/false values.static <T extends java.lang.Enum<T>>
CaseInsensitiveEnumStringArgumentType<T>caseInsensitiveEnumStringType(java.lang.Class<T> type)
ReturnsCaseInsensitiveEnumStringArgumentType
with given enumtype
.static <T extends java.lang.Enum<T>>
CaseInsensitiveEnumNameArgumentType<T>caseInsensitiveEnumType(java.lang.Class<T> type)
ReturnsCaseInsensitiveEnumNameArgumentType
with given enumtype
.static CountArgumentAction
count()
Returns count action.static <T extends java.lang.Enum<T>>
EnumStringArgumentType<T>enumStringType(java.lang.Class<T> type)
ReturnsEnumStringArgumentType
with given enumtype
.static <T extends java.lang.Enum<T>>
EnumArgumentType<T>enumType(java.lang.Class<T> type)
Deprecated.static FileArgumentType
fileType()
Returns newFileArgumentType
object.static HelpArgumentAction
help()
Returns help action.static <T extends java.lang.Comparable<T>>
RangeArgumentChoice<T>range(T min, T max)
Creates new range constrained choice.static StoreArgumentAction
store()
Returns store action.static StoreConstArgumentAction
storeConst()
Returns storeConst action.static StoreFalseArgumentAction
storeFalse()
Returns storeFalse action.static StoreTrueArgumentAction
storeTrue()
Returns storeTrue action.static VersionArgumentAction
version()
Returns version action.
-
-
-
Field Detail
-
store_
private static final StoreArgumentAction store_
-
storeTrue_
private static final StoreTrueArgumentAction storeTrue_
-
storeFalse_
private static final StoreFalseArgumentAction storeFalse_
-
storeConst_
private static final StoreConstArgumentAction storeConst_
-
append_
private static final AppendArgumentAction append_
-
appendConst_
private static final AppendConstArgumentAction appendConst_
-
help_
private static final HelpArgumentAction help_
-
version_
private static final VersionArgumentAction version_
-
count_
private static final CountArgumentAction count_
-
SUPPRESS
public static final FeatureControl SUPPRESS
The value of
FeatureControl.SUPPRESS
.If value is used with
Argument.setDefault(FeatureControl)
, no attribute is added if the command line argument was not present. Otherwise, the default value, which defaults to null, will be added to the object, regardless of the presence of command line argument, returned byArgumentParser.parseArgs(String[])
.
-
-
Method Detail
-
range
public static <T extends java.lang.Comparable<T>> RangeArgumentChoice<T> range(T min, T max)
Creates new range constrained choice.
The value specified in command line will be checked to see whether it fits in given range [min, max], inclusive.
- Type Parameters:
T
- The type of the values in the range- Parameters:
min
- The lower bound of the range, inclusive.max
- The upper bound of the range, inclusive.- Returns:
RangeArgumentChoice
object.
-
store
public static StoreArgumentAction store()
Returns store action.- Returns:
StoreArgumentAction
object.
-
storeTrue
public static StoreTrueArgumentAction storeTrue()
Returns storeTrue action.
If this action is used, the value specified using
Argument.nargs(int)
will be ignored.- Returns:
StoreTrueArgumentAction
object.
-
storeFalse
public static StoreFalseArgumentAction storeFalse()
Returns storeFalse action.
If this action is used, the value specified using
Argument.nargs(int)
will be ignored.- Returns:
StoreFalseArgumentAction
object.
-
storeConst
public static StoreConstArgumentAction storeConst()
Returns storeConst action.
If this action is used, the value specified using
Argument.nargs(int)
will be ignored.- Returns:
StoreConstArgumentAction
object.
-
append
public static AppendArgumentAction append()
Returns append action.
If this action is used, the attribute will be of type
List
. If used withArgument.nargs(int)
, the element of List will be List. This is becauseArgument.nargs(int)
produces List.- Returns:
AppendArgumentAction
object.
-
appendConst
public static AppendConstArgumentAction appendConst()
Returns appendConst action.
If this action is used, the value specified using
Argument.nargs(int)
will be ignored.- Returns:
AppendConstArgumentAction
object.
-
help
public static HelpArgumentAction help()
Returns help action.
This is used for an option printing help message. Please note that this action terminates program after printing help message.
- Returns:
HelpArgumentAction
object.
-
version
public static VersionArgumentAction version()
Returns version action.
This is used for an option printing version message. Please note that this action terminates program after printing version message.
- Returns:
VersionArgumentAction
object.
-
count
public static CountArgumentAction count()
Returns count action.
This action counts the number of occurrence of the option. This action does not consume argument.
- Returns:
CountArgumentAction
object.
-
enumType
@Deprecated public static <T extends java.lang.Enum<T>> EnumArgumentType<T> enumType(java.lang.Class<T> type)
Deprecated.Returns
EnumArgumentType
with given enumtype
.Since enum does not have a constructor with string argument, you cannot use
Argument.type(Class)
. Instead use this convenient function.- Type Parameters:
T
- The type of the enum- Parameters:
type
- The enum type- Returns:
EnumArgumentType
object
-
fileType
public static FileArgumentType fileType()
Returns new
FileArgumentType
object.- Returns:
FileArgumentType
object
-
enumStringType
public static <T extends java.lang.Enum<T>> EnumStringArgumentType<T> enumStringType(java.lang.Class<T> type)
Returns
EnumStringArgumentType
with given enumtype
.Uses
Enum.toString()
instead ofEnum.name()
as the String representation of the enum. For enums that do not overrideEnum.toString()
, this behaves the same asReflectArgumentType
or just useArgument.type(Class)
.- Type Parameters:
T
- The type of the enum- Parameters:
type
- The enum type- Returns:
EnumStringArgumentType
object
-
caseInsensitiveEnumType
public static <T extends java.lang.Enum<T>> CaseInsensitiveEnumNameArgumentType<T> caseInsensitiveEnumType(java.lang.Class<T> type)
Returns
CaseInsensitiveEnumNameArgumentType
with given enumtype
.Uses
Enum.name()
as the String representation of the enum.- Type Parameters:
T
- The type of the enum- Parameters:
type
- The enum type- Returns:
CaseInsensitiveEnumNameArgumentType
object- Since:
- 0.8.0
-
caseInsensitiveEnumStringType
public static <T extends java.lang.Enum<T>> CaseInsensitiveEnumStringArgumentType<T> caseInsensitiveEnumStringType(java.lang.Class<T> type)
Returns
CaseInsensitiveEnumStringArgumentType
with given enumtype
.Uses
Enum.toString()
instead ofEnum.name()
as the String representation of the enum. For enums that do not overrideEnum.toString()
, this behaves the same asCaseInsensitiveEnumNameArgumentType
.- Type Parameters:
T
- The type of the enum- Parameters:
type
- The enum type- Returns:
CaseInsensitiveEnumStringArgumentType
object- Since:
- 0.8.0
-
booleanType
public static BooleanArgumentType booleanType()
Returns
BooleanArgumentType
with "true" as true value, and "false" as false value.Read
BooleanArgumentType
documentation to know the difference between the use ofBooleanArgumentType
and passingBoolean
class toArgument.type(Class)
.- Returns:
- The BooleanArgumentType object
- Since:
- 0.7.0
-
booleanType
public static BooleanArgumentType booleanType(java.lang.String trueValue, java.lang.String falseValue)
Returns
BooleanArgumentType
with given true/false values.Read
BooleanArgumentType
documentation to know the difference between the use ofBooleanArgumentType
and passingBoolean
class toArgument.type(Class)
.- Parameters:
trueValue
- string used as true valuefalseValue
- string used as false value- Returns:
- The BooleanArgumentType object
- Since:
- 0.7.0
-
-