Class AbstractMainSupport<A,R>
- java.lang.Object
-
- cdc.util.cli.AbstractMainSupport<A,R>
-
- Type Parameters:
A- MainArgs type.R- Returned type.
public abstract class AbstractMainSupport<A,R> extends Object
Utility that can be used to create main programs.The purpose is to force the adoption of a common pattern for such classes.
Some options are automatically defined and handled:
- help: if passed, help is printed and program is exited.
- version: if passed, version is printed and program is exited.
OverridegetVersion()to define version. - args-list <FILE>: if passed, command line arguments
are read from the designated file and added to other command line arguments.
This is useful when command line is too long.
OverrideaddArgsFileOption(Options)to force its presence.
The file must contains one argument (option of value) per line.
A line that is empty or starts with any number of white spaces followed by '#' and any other characters is a ignored.
Exemple:
# (ignored) --option1 --option2 --option3 value1 value2 # (ignored) value3- Author:
- Damien Carbonne
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceAbstractMainSupport.Maskable<E extends Enum<E>>
-
Field Summary
Fields Modifier and Type Field Description static StringARGS_FILEstatic StringCHARSETstatic StringDEFAULT_PARTS_SEPARATORstatic StringDRIVERstatic StringHELPstatic StringINPUTstatic StringINPUT_DIRstatic StringOUTPUTstatic StringOUTPUT_DIRstatic StringPASSWORDstatic StringPATHstatic StringPREFIXstatic StringTMP_DIRstatic StringURLstatic StringUSERstatic StringVERSION
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractMainSupport(Class<?> mainClass, org.apache.logging.log4j.Logger logger)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected booleanaddArgsFileOption(org.apache.commons.cli.Options options)ReturnstrueifARGS_FILEoption must be added.static <E extends Enum<E> & OptionEnum>
voidaddGroupedNoArgOptions(org.apache.commons.cli.Options options, Class<E> enumClass, boolean required)static <E extends Enum<E> & OptionEnum>
voidaddNoArgOptions(org.apache.commons.cli.Options options, Class<E> enumClass)protected abstract voidaddSpecificOptions(org.apache.commons.cli.Options options)Creates specific options and add them to an options collection.protected voidaddStandardOptions(org.apache.commons.cli.Options options)protected abstract Aanalyze(org.apache.commons.cli.CommandLine cl)Analyzes the command line.protected org.apache.commons.cli.OptionsbuildOptions()Creates options, add standard and specific options and returns them.static <E extends Enum<E> & OptionEnum>
org.apache.commons.cli.OptionGroupcreateGroup(org.apache.commons.cli.Options options, boolean required, E... values)static <E extends Enum<E> & OptionEnum>
org.apache.commons.cli.OptionGroupcreateGroup(org.apache.commons.cli.Options options, E... values)protected abstract Rexecute(A margs)Executes the main program.static voidfillValues(org.apache.commons.cli.CommandLine cl, String opt, Collection<String> values)static <T> voidfillValues(org.apache.commons.cli.CommandLine cl, String opt, Collection<T> values, Function<String,T> converter)protected StringgetHelpFooter()Returns the help footer.protected StringgetHelpHeader()Returns the help header.protected org.apache.logging.log4j.LoggergetLogger()static intgetNumberOfParts(String s, String sep)protected org.apache.commons.cli.OptionsgetOptionsAsOptional()static StringgetPart(String s, String sep, int index)static StringgetPart(String s, String sep, int index, String def)static <T> TgetValue(org.apache.commons.cli.CommandLine cl, String opt, T def, Function<String,T> converter)Returns the conversion of an option value to a type or a default value.static bytegetValueAsByte(org.apache.commons.cli.CommandLine cl, String opt, byte def)Returns an option value as a byte.static BytegetValueAsByte(org.apache.commons.cli.CommandLine cl, String opt, Byte def)static chargetValueAsChar(org.apache.commons.cli.CommandLine cl, String opt, char def)Returns an option value as a char.static CharactergetValueAsChar(org.apache.commons.cli.CommandLine cl, String opt, Character def)static FilegetValueAsDirectory(org.apache.commons.cli.CommandLine cl, String opt)static FilegetValueAsDirectory(org.apache.commons.cli.CommandLine cl, String opt, File def)static doublegetValueAsDouble(org.apache.commons.cli.CommandLine cl, String opt, double def)Returns an option value as a double.static DoublegetValueAsDouble(org.apache.commons.cli.CommandLine cl, String opt, Double def)static <E extends Enum<E>>
EgetValueAsEnum(org.apache.commons.cli.CommandLine cl, String opt, Class<E> enumClass, E def)Returns an option value as a enum.static FilegetValueAsExistingDirectory(org.apache.commons.cli.CommandLine cl, String opt)static FilegetValueAsExistingDirectory(org.apache.commons.cli.CommandLine cl, String opt, File def)static FilegetValueAsExistingFile(org.apache.commons.cli.CommandLine cl, String opt)static FilegetValueAsExistingFile(org.apache.commons.cli.CommandLine cl, String opt, File def)static FilegetValueAsExistingFileOrDirectory(org.apache.commons.cli.CommandLine cl, String opt)static FilegetValueAsExistingFileOrDirectory(org.apache.commons.cli.CommandLine cl, String opt, File def)static FilegetValueAsFile(org.apache.commons.cli.CommandLine cl, String opt)static FilegetValueAsFile(org.apache.commons.cli.CommandLine cl, String opt, File def)Returns an option value as a File.static floatgetValueAsFloat(org.apache.commons.cli.CommandLine cl, String opt, float def)Returns an option value as a float.static FloatgetValueAsFloat(org.apache.commons.cli.CommandLine cl, String opt, Float def)static intgetValueAsInt(org.apache.commons.cli.CommandLine cl, String opt, int def)Returns an option value as an int.static IntegergetValueAsInt(org.apache.commons.cli.CommandLine cl, String opt, Integer def)static longgetValueAsLong(org.apache.commons.cli.CommandLine cl, String opt, long def)Returns an option value as a long.static LonggetValueAsLong(org.apache.commons.cli.CommandLine cl, String opt, Long def)static FilegetValueAsNullOrExistingDirectory(org.apache.commons.cli.CommandLine cl, String opt)static FilegetValueAsNullOrExistingDirectory(org.apache.commons.cli.CommandLine cl, String opt, File def)Returns an option value as an existing directory or null.static FilegetValueAsNullOrExistingFile(org.apache.commons.cli.CommandLine cl, String opt)static FilegetValueAsNullOrExistingFile(org.apache.commons.cli.CommandLine cl, String opt, File def)Returns an option value as an existing file or null.static FilegetValueAsNullOrExistingFileOrDirectory(org.apache.commons.cli.CommandLine cl, String opt)static FilegetValueAsNullOrExistingFileOrDirectory(org.apache.commons.cli.CommandLine cl, String opt, File def)Returns an option value as an existing file or directory or null.static shortgetValueAsShort(org.apache.commons.cli.CommandLine cl, String opt, short def)Returns an option value as a short.static ShortgetValueAsShort(org.apache.commons.cli.CommandLine cl, String opt, Short def)static StringgetValueAsString(org.apache.commons.cli.CommandLine cl, String opt, String def)Returns an option value as a string.static URLgetValueAsURL(org.apache.commons.cli.CommandLine cl, String opt)static URLgetValueAsURL(org.apache.commons.cli.CommandLine cl, String opt, URL def)Returns an option value as an URL.static <T> List<T>getValues(org.apache.commons.cli.CommandLine cl, String opt, Function<String,T> converter)protected StringgetVersion()Returns the version.Rmain(String[] args)Default main program.protected voidprintHelp(org.apache.commons.cli.Options options, Exception e)protected voidprintVersion()static <E extends Enum<E> & OptionEnum>
voidsetMask(org.apache.commons.cli.CommandLine cl, Class<E> enumClass, AbstractMainSupport.Maskable<E> maskable)
-
-
-
Field Detail
-
DEFAULT_PARTS_SEPARATOR
public static final String DEFAULT_PARTS_SEPARATOR
- See Also:
- Constant Field Values
-
ARGS_FILE
public static final String ARGS_FILE
- See Also:
- Constant Field Values
-
CHARSET
public static final String CHARSET
- See Also:
- Constant Field Values
-
DRIVER
public static final String DRIVER
- See Also:
- Constant Field Values
-
HELP
public static final String HELP
- See Also:
- Constant Field Values
-
INPUT
public static final String INPUT
- See Also:
- Constant Field Values
-
INPUT_DIR
public static final String INPUT_DIR
- See Also:
- Constant Field Values
-
OUTPUT
public static final String OUTPUT
- See Also:
- Constant Field Values
-
OUTPUT_DIR
public static final String OUTPUT_DIR
- See Also:
- Constant Field Values
-
PASSWORD
public static final String PASSWORD
- See Also:
- Constant Field Values
-
PATH
public static final String PATH
- See Also:
- Constant Field Values
-
PREFIX
public static final String PREFIX
- See Also:
- Constant Field Values
-
TMP_DIR
public static final String TMP_DIR
- See Also:
- Constant Field Values
-
URL
public static final String URL
- See Also:
- Constant Field Values
-
USER
public static final String USER
- See Also:
- Constant Field Values
-
VERSION
public static final String VERSION
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractMainSupport
protected AbstractMainSupport(Class<?> mainClass, org.apache.logging.log4j.Logger logger)
-
-
Method Detail
-
addArgsFileOption
protected boolean addArgsFileOption(org.apache.commons.cli.Options options)
ReturnstrueifARGS_FILEoption must be added.The default implementation returns
trueif one option contains multiple values.- Parameters:
options- The options.- Returns:
trueifARGS_FILEoption must be added.
-
addStandardOptions
protected void addStandardOptions(org.apache.commons.cli.Options options)
-
getLogger
protected final org.apache.logging.log4j.Logger getLogger()
-
getVersion
protected String getVersion()
Returns the version.If
nullis returned (default implementation), no version option is available.- Returns:
- The version.
-
getHelpHeader
protected String getHelpHeader()
Returns the help header.If
nullis returned (default implementation), no help header is printed.- Returns:
- The help header.
-
getHelpFooter
protected String getHelpFooter()
Returns the help footer.If
nullis returned (default implementation), no help footer is printed.- Returns:
- The help footer.
-
addSpecificOptions
protected abstract void addSpecificOptions(org.apache.commons.cli.Options options)
Creates specific options and add them to an options collection.The standard options must not be added.
- Parameters:
options- The options.
-
analyze
protected abstract A analyze(org.apache.commons.cli.CommandLine cl) throws org.apache.commons.cli.ParseException
Analyzes the command line.These options are already handled:
- help
- version
- args-file
- Parameters:
cl- The command line.- Returns:
- A MainARgs instance.
- Throws:
org.apache.commons.cli.ParseException- When command line parsing has a problem.
-
execute
protected abstract R execute(A margs) throws Exception
Executes the main program.- Parameters:
margs- The main arguments.- Returns:
- The optional result.
- Throws:
Exception- When program has a problem.
-
addNoArgOptions
public static <E extends Enum<E> & OptionEnum> void addNoArgOptions(org.apache.commons.cli.Options options, Class<E> enumClass)
-
addGroupedNoArgOptions
public static <E extends Enum<E> & OptionEnum> void addGroupedNoArgOptions(org.apache.commons.cli.Options options, Class<E> enumClass, boolean required)
-
createGroup
@SafeVarargs public static <E extends Enum<E> & OptionEnum> org.apache.commons.cli.OptionGroup createGroup(org.apache.commons.cli.Options options, boolean required, E... values)
-
createGroup
@SafeVarargs public static <E extends Enum<E> & OptionEnum> org.apache.commons.cli.OptionGroup createGroup(org.apache.commons.cli.Options options, E... values)
-
setMask
public static <E extends Enum<E> & OptionEnum> void setMask(org.apache.commons.cli.CommandLine cl, Class<E> enumClass, AbstractMainSupport.Maskable<E> maskable)
-
main
public R main(String[] args)
Default main program.This does the following things:
- Build options.
- Parse the command line strings and creates a CommandLine instance.
- Analyze the CommandLine instance and create a MainArgs instance.
- Calls execute with the MainARgs instance.
- Parameters:
args- The command line arguments.- Returns:
- The optional result.
-
buildOptions
protected org.apache.commons.cli.Options buildOptions()
Creates options, add standard and specific options and returns them.- Returns:
- The options.
-
getOptionsAsOptional
protected org.apache.commons.cli.Options getOptionsAsOptional()
- Returns:
- Build all options and make them optional.
-
printHelp
protected void printHelp(org.apache.commons.cli.Options options, Exception e)
-
printVersion
protected void printVersion()
-
getValue
public static <T> T getValue(org.apache.commons.cli.CommandLine cl, String opt, T def, Function<String,T> converter) throws org.apache.commons.cli.ParseExceptionReturns the conversion of an option value to a type or a default value.If the option is present, tries to convert its value to
<T>usingconverter.
If the conversion succeeds, returns its result, otherwise throws aParseException.
If the option is absent, returns the passeddef.- Type Parameters:
T- The result type.- Parameters:
cl- The command line.opt- The option name.def- Default value. MAY BE null.converter- Function used to convert a String to the expected type.- Returns:
- The conversion of the option value to
<Y>type ordef. - Throws:
org.apache.commons.cli.ParseException- If result could not be converted.
-
fillValues
public static void fillValues(org.apache.commons.cli.CommandLine cl, String opt, Collection<String> values)
-
fillValues
public static <T> void fillValues(org.apache.commons.cli.CommandLine cl, String opt, Collection<T> values, Function<String,T> converter) throws org.apache.commons.cli.ParseException- Throws:
org.apache.commons.cli.ParseException
-
getValues
public static <T> List<T> getValues(org.apache.commons.cli.CommandLine cl, String opt, Function<String,T> converter) throws org.apache.commons.cli.ParseException
- Throws:
org.apache.commons.cli.ParseException
-
getValueAsFile
public static File getValueAsFile(org.apache.commons.cli.CommandLine cl, String opt, File def) throws org.apache.commons.cli.ParseException
Returns an option value as a File.If option is absent, returns a default value.
Result is null only when option does not exist and default value is null.- Parameters:
cl- The command line.opt- The option name.def- Default value.- Returns:
- The option value as a File.
- Throws:
org.apache.commons.cli.ParseException- If result could not be produced.
-
getValueAsFile
public static File getValueAsFile(org.apache.commons.cli.CommandLine cl, String opt) throws org.apache.commons.cli.ParseException
- Throws:
org.apache.commons.cli.ParseException
-
getValueAsExistingFile
public static File getValueAsExistingFile(org.apache.commons.cli.CommandLine cl, String opt, File def) throws org.apache.commons.cli.ParseException
- Throws:
org.apache.commons.cli.ParseException
-
getValueAsExistingFile
public static File getValueAsExistingFile(org.apache.commons.cli.CommandLine cl, String opt) throws org.apache.commons.cli.ParseException
- Throws:
org.apache.commons.cli.ParseException
-
getValueAsDirectory
public static File getValueAsDirectory(org.apache.commons.cli.CommandLine cl, String opt, File def) throws org.apache.commons.cli.ParseException
- Throws:
org.apache.commons.cli.ParseException
-
getValueAsDirectory
public static File getValueAsDirectory(org.apache.commons.cli.CommandLine cl, String opt) throws org.apache.commons.cli.ParseException
- Throws:
org.apache.commons.cli.ParseException
-
getValueAsNullOrExistingFile
public static File getValueAsNullOrExistingFile(org.apache.commons.cli.CommandLine cl, String opt, File def) throws org.apache.commons.cli.ParseException
Returns an option value as an existing file or null.If option is absent, returns a default value (possibly null).
If result is not null and does not exist as a file, throws an exception.
To obtain a null result :- default value must be set to null.
- option must be absent.
- Parameters:
cl- The command line.opt- The option name.def- Default value. MAY BE null.- Returns:
- The option value or default value. Is either an existing file or null.
- Throws:
org.apache.commons.cli.ParseException- If result is not null and does not exist.
-
getValueAsNullOrExistingFile
public static File getValueAsNullOrExistingFile(org.apache.commons.cli.CommandLine cl, String opt) throws org.apache.commons.cli.ParseException
- Throws:
org.apache.commons.cli.ParseException
-
getValueAsExistingDirectory
public static File getValueAsExistingDirectory(org.apache.commons.cli.CommandLine cl, String opt, File def) throws org.apache.commons.cli.ParseException
- Throws:
org.apache.commons.cli.ParseException
-
getValueAsExistingDirectory
public static File getValueAsExistingDirectory(org.apache.commons.cli.CommandLine cl, String opt) throws org.apache.commons.cli.ParseException
- Throws:
org.apache.commons.cli.ParseException
-
getValueAsNullOrExistingDirectory
public static File getValueAsNullOrExistingDirectory(org.apache.commons.cli.CommandLine cl, String opt, File def) throws org.apache.commons.cli.ParseException
Returns an option value as an existing directory or null.If option is absent, returns a default value (possibly null).
If result is not null and does not exist as a directory, throws an exception.
To obtain a null result :- default value must be set to null.
- option must be absent.
- Parameters:
cl- The command line.opt- The option name.def- Default value.- Returns:
- The option value or default value. Is either an existing directory or null.
- Throws:
org.apache.commons.cli.ParseException- If result is not null and does not exist.
-
getValueAsNullOrExistingDirectory
public static File getValueAsNullOrExistingDirectory(org.apache.commons.cli.CommandLine cl, String opt) throws org.apache.commons.cli.ParseException
- Throws:
org.apache.commons.cli.ParseException
-
getValueAsExistingFileOrDirectory
public static File getValueAsExistingFileOrDirectory(org.apache.commons.cli.CommandLine cl, String opt, File def) throws org.apache.commons.cli.ParseException
- Throws:
org.apache.commons.cli.ParseException
-
getValueAsExistingFileOrDirectory
public static File getValueAsExistingFileOrDirectory(org.apache.commons.cli.CommandLine cl, String opt) throws org.apache.commons.cli.ParseException
- Throws:
org.apache.commons.cli.ParseException
-
getValueAsNullOrExistingFileOrDirectory
public static File getValueAsNullOrExistingFileOrDirectory(org.apache.commons.cli.CommandLine cl, String opt, File def) throws org.apache.commons.cli.ParseException
Returns an option value as an existing file or directory or null.If option is absent, returns a default value (possibly null).
If result is not null and does not exist as a file or directory, throws an exception.
To obtain a null result :- default value must be set to null.
- option must be absent.
- Parameters:
cl- The command line.opt- The option name.def- Default value.- Returns:
- The option value or default value. Is either an existing file or directory or null.
- Throws:
org.apache.commons.cli.ParseException- If result is not null and does not exist.
-
getValueAsNullOrExistingFileOrDirectory
public static File getValueAsNullOrExistingFileOrDirectory(org.apache.commons.cli.CommandLine cl, String opt) throws org.apache.commons.cli.ParseException
- Throws:
org.apache.commons.cli.ParseException
-
getValueAsURL
public static URL getValueAsURL(org.apache.commons.cli.CommandLine cl, String opt, URL def) throws org.apache.commons.cli.ParseException
Returns an option value as an URL.If option is absent, returns a default value (possibly null).
If option is present and can be converted to an URL, returns this conversion.
Otherwise, raises an exception.- Parameters:
cl- The command line.opt- The option name.def- Default value.- Returns:
- The option value or default value.
- Throws:
org.apache.commons.cli.ParseException- If option is present and can not be converted to a valid URL.
-
getValueAsURL
public static URL getValueAsURL(org.apache.commons.cli.CommandLine cl, String opt) throws org.apache.commons.cli.ParseException
- Throws:
org.apache.commons.cli.ParseException
-
getValueAsString
public static String getValueAsString(org.apache.commons.cli.CommandLine cl, String opt, String def)
Returns an option value as a string.If option is absent, returns a default value.
- Parameters:
cl- The command line.opt- The option name.def- Default value.- Returns:
- The option value as a string.
-
getValueAsChar
public static char getValueAsChar(org.apache.commons.cli.CommandLine cl, String opt, char def) throws org.apache.commons.cli.ParseExceptionReturns an option value as a char.If option is absent, returns a default value.
- Parameters:
cl- The command line.opt- The option name.def- Default value.- Returns:
- The option value as a char.
- Throws:
org.apache.commons.cli.ParseException- If the option value can not be parsed as a char.
-
getValueAsChar
public static Character getValueAsChar(org.apache.commons.cli.CommandLine cl, String opt, Character def) throws org.apache.commons.cli.ParseException
- Throws:
org.apache.commons.cli.ParseException
-
getValueAsLong
public static long getValueAsLong(org.apache.commons.cli.CommandLine cl, String opt, long def) throws org.apache.commons.cli.ParseExceptionReturns an option value as a long.If option is absent, returns a default value.
- Parameters:
cl- The command line.opt- The option name.def- Default value.- Returns:
- The option value as a long.
- Throws:
org.apache.commons.cli.ParseException- If the option value can not be parsed as a long.
-
getValueAsLong
public static Long getValueAsLong(org.apache.commons.cli.CommandLine cl, String opt, Long def) throws org.apache.commons.cli.ParseException
- Throws:
org.apache.commons.cli.ParseException
-
getValueAsInt
public static int getValueAsInt(org.apache.commons.cli.CommandLine cl, String opt, int def) throws org.apache.commons.cli.ParseExceptionReturns an option value as an int.If option is absent, returns a default value.
- Parameters:
cl- The command line.opt- The option name.def- Default value.- Returns:
- The option value as an int.
- Throws:
org.apache.commons.cli.ParseException- If the option value can not be parsed as an int.
-
getValueAsInt
public static Integer getValueAsInt(org.apache.commons.cli.CommandLine cl, String opt, Integer def) throws org.apache.commons.cli.ParseException
- Throws:
org.apache.commons.cli.ParseException
-
getValueAsShort
public static short getValueAsShort(org.apache.commons.cli.CommandLine cl, String opt, short def) throws org.apache.commons.cli.ParseExceptionReturns an option value as a short.If option is absent, returns a default value.
- Parameters:
cl- The command line.opt- The option name.def- Default value.- Returns:
- The option value as a short.
- Throws:
org.apache.commons.cli.ParseException- If the option value can not be parsed as a short.
-
getValueAsShort
public static Short getValueAsShort(org.apache.commons.cli.CommandLine cl, String opt, Short def) throws org.apache.commons.cli.ParseException
- Throws:
org.apache.commons.cli.ParseException
-
getValueAsByte
public static byte getValueAsByte(org.apache.commons.cli.CommandLine cl, String opt, byte def) throws org.apache.commons.cli.ParseExceptionReturns an option value as a byte.If option is absent, returns a default value.
- Parameters:
cl- The command line.opt- The option name.def- Default value.- Returns:
- The option value as a byte.
- Throws:
org.apache.commons.cli.ParseException- If the option value can not be parsed as a byte.
-
getValueAsByte
public static Byte getValueAsByte(org.apache.commons.cli.CommandLine cl, String opt, Byte def) throws org.apache.commons.cli.ParseException
- Throws:
org.apache.commons.cli.ParseException
-
getValueAsDouble
public static double getValueAsDouble(org.apache.commons.cli.CommandLine cl, String opt, double def) throws org.apache.commons.cli.ParseExceptionReturns an option value as a double.If option is absent, returns a default value.
- Parameters:
cl- The command line.opt- The option name.def- Default value.- Returns:
- The option value as a double.
- Throws:
org.apache.commons.cli.ParseException- If the option value can not be parsed as a double.
-
getValueAsDouble
public static Double getValueAsDouble(org.apache.commons.cli.CommandLine cl, String opt, Double def) throws org.apache.commons.cli.ParseException
- Throws:
org.apache.commons.cli.ParseException
-
getValueAsFloat
public static float getValueAsFloat(org.apache.commons.cli.CommandLine cl, String opt, float def) throws org.apache.commons.cli.ParseExceptionReturns an option value as a float.If option is absent, returns a default value.
- Parameters:
cl- The command line.opt- The option name.def- Default value.- Returns:
- The option value as a float.
- Throws:
org.apache.commons.cli.ParseException- If the option value can not be parsed as a float.
-
getValueAsFloat
public static Float getValueAsFloat(org.apache.commons.cli.CommandLine cl, String opt, Float def) throws org.apache.commons.cli.ParseException
- Throws:
org.apache.commons.cli.ParseException
-
getValueAsEnum
public static <E extends Enum<E>> E getValueAsEnum(org.apache.commons.cli.CommandLine cl, String opt, Class<E> enumClass, E def) throws org.apache.commons.cli.ParseException
Returns an option value as a enum.If option is absent, returns a default value.
- Type Parameters:
E- The enum type.- Parameters:
cl- The command line.opt- The option name.enumClass- Enum classdef- Default value.- Returns:
- The option value as an enum.
- Throws:
org.apache.commons.cli.ParseException- If the option value can not be parsed as an enum value.
-
-