Apache Commons logo Apache Commons CLI

Defining Option Properties

The following are the properties that each Option has. All of these can be set using the accessors or using the methods defined in the Option.Builder.

Name Type Description
arg boolean A flag to say whether the option takes an argument.
args boolean A flag to say whether the option takes more than one argument.
argName java.lang.String The name of the argument value for the usage statement.
converter org.apache.commons.cli.Converter<T, E extends Throwable> A FunctionalInterface that converts a String to type T and may throw an exception E. When CommandLine.getParsedValue() is called this FunctionalInterface will perform the conversion from the command line argument to the parsed type. This is used when a desired type is not registered, or to provide a custom type implementation. The 'type' property is not required to use the 'converter' property.
deprecated org.apache.commons.cli.DeprecatedAttributes Marks the option as deprecated and has the deprecation properties.
description java.lang.String A description of the function of the option.
longOpt java.lang.String An alias and more descriptive identification string. May be null or not specified if 'opt' is provided.
opt java.lang.String The identification string of the Option. May be null or not specified if 'longOpt' is provided.
optionalArg boolean A flag to say whether the option's argument is optional.
required boolean A flag to say whether the option must appear on the command line.
type java.lang.Class<?> The class of the object returned from getParsedValue(). The class must be registered in TypeHandler instance. See also 'converter' property.
value java.lang.String The value of the option.
values java.lang.String[] The values of the option.
valueSeparator char The character value used to split the argument string, that is used in conjunction with multipleArgs e.g. if the separator is ',' and the argument string is 'a,b,c' then there are three argument values, 'a', 'b' and 'c'.