Class CLAParser
- java.lang.Object
-
- snaq.util.jclap.CLAParser
-
public final class CLAParser extends Object
Utility class to provide support for command-line options parsing.Supports both POSIX-style short-form (e.g.
-v) and GNU-style long-form (e.g.--verbose) options. The short-form is mandatory, and the long-form optional.Processing of options can be explicitly terminated by the argument "
--", to allow (non-option) arguments to be specified.All options must have at least a short name, and are recommended to also have a long name. Options that require a value have the value specified immediately after the option name on the command-line.
For example, an option to display a help message might be specified with the short name
?and the long namehelp(shown as[-?,--help]in the long usage message). An option for a size value might be specified as[-s,--size]and require a value parameter, which may be specified in any of these forms:-s 123-s=123-s:123/s 123/s=123/s:123--size 123--size=123--size:123
There is also support for automatic usage message based on the configured options. For example, an instance which has three options configured
{ w, h, ? }with long-names{ width, height, help }and onlywbeing mandatory, might have a short usage message as follows:java AppName -w <integer> [-h <integer>] [-?]and a long usage message as follows:java AppName <options> Options: -w,--width <integer> (mandatory) Width of image. [-h,--height <integer>] Height of image. [-?,--help] Display help information.Here's a summary of JCLAP features:
- Option short names are mandatory, and long names optional (as per POSIX standard, but retaining GNU enhancements).
- Supports enumerated option types (String, Integer).
- Supports filtered string option types.
- Supports file/folder option types (using filtered-string feature).
- Support for automatic usage printing (both long & short styles).
- Supports custom application launch text for automatic usage.
- Supports non-option argument text for automatic usage.
- Supports custom extra info text for automatic usage.
- Uses a single
OptionExceptiontype for signalling problems. - Supports query for single-hyphen argument to facilitate reading from STDIN.
- Internationalization support.
Automatic usage printing can be accessed via the
printUsage(...)method, allowing printing to a specifiedPrintStreamin either long or short versions. The options are printed in the same order in which they were added to theCLAParserinstance. The command used to launch the application can either be user-specified, or can be deduced automatically if required. Internationalization support is included for a few locales (en/fr/de/es/pt), and may be extended in future. If required users may author their own locale property files to reference.For an example of how to use the CLAParser class, visit the website.
- Author:
- Giles Winstanley
- See Also:
- JCLAP website
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Option<Boolean>addBooleanOption(String shortName)Convenience method to add anOptionof typeBoolean(single value allowed).Option<Boolean>addBooleanOption(String shortName, boolean allowMany)Convenience method to add anOptionof typeBoolean.Option<Boolean>addBooleanOption(String shortName, int maxCount)Convenience method to add anOptionof typeBoolean.Option<Boolean>addBooleanOption(String shortName, String longName, String description)Convenience method to add anOptionof typeBoolean(single value allowed).Option<Boolean>addBooleanOption(String shortName, String longName, String description, boolean allowMany)Convenience method to add anOptionof typeBoolean.Option<Boolean>addBooleanOption(String shortName, String longName, String description, int maxCount)Convenience method to add anOptionof typeBoolean.Option<Boolean>addBooleanOption(String shortName, String longName, String description, int minCount, int maxCount)Convenience method to add anOptionof typeBoolean.Option<String>addDirectoryExistingOption(String shortName, String longName, String description, boolean mandatory, boolean allowMany)Convenience method to add anOptionof typeStringwhich refers to an existing folder.Option<String>addDirectoryExistingOption(String shortName, String longName, String description, int minCount, int maxCount)Convenience method to add anOptionof typeStringwhich refers to an existing folder.Option<Double>addDoubleOption(String shortName, boolean mandatory, boolean allowMany)Convenience method to add anOptionof typeDouble.Option<Double>addDoubleOption(String shortName, int minCount, int maxCount)Convenience method to add anOptionof typeDouble.Option<Double>addDoubleOption(String shortName, String longName, String description, boolean mandatory, boolean allowMany)Convenience method to add anOptionof typeDouble.Option<Double>addDoubleOption(String shortName, String longName, String description, int minCount, int maxCount)Convenience method to add anOptionof typeDouble.Option<Integer>addEnumIntegerOption(String shortName, String longName, String description, boolean mandatory, boolean allowMany, int[] allowedValues)Convenience method to add anOptionof enumeratedIntegertype.Option<Integer>addEnumIntegerOption(String shortName, String longName, String description, int[] allowedValues)Convenience method to add anOptionof enumeratedIntegertype (single value allowed, non-mandatory).Option<String>addEnumStringOption(String shortName, String longName, String description, boolean mandatory, boolean allowMany, String[] allowedValues)Convenience method to add anOptionof enumeratedStringtype (case-insensitive string matching).Option<String>addEnumStringOption(String shortName, String longName, String description, boolean mandatory, boolean allowMany, String[] allowedValues, boolean ignoreCase)Convenience method to add anOptionof enumeratedStringtype.Option<String>addEnumStringOption(String shortName, String longName, String description, int minCount, int maxCount, String[] allowedValues, boolean ignoreCase)Convenience method to add anOptionof enumeratedStringtype.Option<String>addEnumStringOption(String shortName, String longName, String description, String[] allowedValues)Convenience method to add anOptionof enumeratedStringtype (single value allowed, non-mandatory).Option<String>addFileExistingOption(String shortName, String longName, String description, boolean mandatory, boolean allowMany)Convenience method to add anOptionof typeStringwhich refers to an existing file (which is not a folder).Option<String>addFileExistingOption(String shortName, String longName, String description, int minCount, int maxCount)Convenience method to add anOptionof typeStringwhich refers to an existing file (which is not a folder).Option<String>addFileNewOption(String shortName, String longName, String description, boolean mandatory, boolean allowMany)Convenience method to add anOptionof typeStringwhich refers to a new or existing file/folder.Option<String>addFileOption(String shortName, String longName, String description, boolean mandatory, boolean allowMany)Convenience method to add anOptionof typeStringwhich refers to a file/folder.Option<Float>addFloatOption(String shortName, boolean mandatory, boolean allowMany)Convenience method to add anOptionof typeFloat.Option<Float>addFloatOption(String shortName, int minCount, int maxCount)Convenience method to add anOptionof typeFloat.Option<Float>addFloatOption(String shortName, String longName, String description, boolean mandatory, boolean allowMany)Convenience method to add anOptionof typeFloat.Option<Float>addFloatOption(String shortName, String longName, String description, int minCount, int maxCount)Convenience method to add anOptionof typeFloat.Option<String>addFolderExistingOption(String shortName, String longName, String description, boolean mandatory, boolean allowMany)Deprecated.Option<String>addFolderExistingOption(String shortName, String longName, String description, int minCount, int maxCount)Deprecated.Option<Integer>addIntegerOption(String shortName, boolean mandatory, boolean allowMany)Convenience method to add anOptionof typeInteger.Option<Integer>addIntegerOption(String shortName, int minCount, int maxCount)Convenience method to add anOptionof typeInteger.Option<Integer>addIntegerOption(String shortName, String longName, String description, boolean mandatory, boolean allowMany)Convenience method to add anOptionof typeInteger.Option<Integer>addIntegerOption(String shortName, String longName, String description, int minCount, int maxCount)Convenience method to add anOptionof typeInteger.Option<LocalDate>addLocalDateOption(String shortName, boolean mandatory, boolean allowMany)Convenience method to add anOptionof typeLocalDate(no long name, no description).Option<LocalDate>addLocalDateOption(String shortName, int minCount, int maxCount)Convenience method to add anOptionof typeLocalDate(no long name, no description).Option<LocalDate>addLocalDateOption(String shortName, String longName, String description)Convenience method to add anOptionof typeLocalDate(single value allowed, non-mandatory).Option<LocalDate>addLocalDateOption(String shortName, String longName, String description, boolean mandatory, boolean allowMany)Convenience method to add anOptionof typeLocalDate.Option<LocalDate>addLocalDateOption(String shortName, String longName, String description, int minCount, int maxCount)Convenience method to add anOptionof typeLocalDate.Option<Long>addLongOption(String shortName, boolean mandatory, boolean allowMany)Convenience method to add anOptionof typeLong.Option<Long>addLongOption(String shortName, int minCount, int maxCount)Convenience method to add anOptionof typeLong.Option<Long>addLongOption(String shortName, String longName, String description, boolean mandatory, boolean allowMany)Convenience method to add anOptionof typeLong.Option<Long>addLongOption(String shortName, String longName, String description, int minCount, int maxCount)Convenience method to add anOptionof typeLong.<T> Option<T>addOption(Option<T> opt)Adds the specifiedOptionto the list of those to be parsed from the command-line arguments.Option<String>addStringOption(String shortName, boolean mandatory, boolean allowMany)Convenience method to add anOptionof typeString(no long name, no description).Option<String>addStringOption(String shortName, int minCount, int maxCount)Convenience method to add anOptionof typeString(no long name, no description).Option<String>addStringOption(String shortName, String longName, String description)Convenience method to add anOptionof typeString(single value allowed, non-mandatory).Option<String>addStringOption(String shortName, String longName, String description, boolean mandatory, boolean allowMany)Convenience method to add anOptionof typeString.Option<String>addStringOption(String shortName, String longName, String description, int minCount, int maxCount)Convenience method to add anOptionof typeString.BooleangetBooleanOptionValue(String optionName)Convenience method to return the parsed value of the named option, orfalseif the option was not set.BooleangetBooleanOptionValue(String optionName, Boolean def)Convenience method to return the parsed value of the named option, or the specified default value if the option was not set.List<Boolean>getBooleanOptionValues(String optionName)Returns a list of all the parsed values for the specified option, or an empty list if the option was not set.DoublegetDoubleOptionValue(String optionName)Convenience method to return the parsed value of the named option, or null if the option was not set.DoublegetDoubleOptionValue(String optionName, Double def)Convenience method to return the parsed value of the named option, or the specified default value if the option was not set.List<Double>getDoubleOptionValues(String optionName)Returns a list of all the parsed values for the specified option, or an empty list if the option was not set.FilegetFileOptionValue(String optionName)Convenience method to return the parsed value of the named option, or null if the option was not set.FilegetFileOptionValue(String optionName, File def)Convenience method to return the parsed value of the named option, or the specified default value if the option was not set.List<File>getFileOptionValues(String optionName)Returns a list of all the parsed values for the specified option, or an empty list if the option was not set.FloatgetFloatOptionValue(String optionName)Convenience method to return the parsed value of the named option, or null if the option was not set.FloatgetFloatOptionValue(String optionName, Float def)Convenience method to return the parsed value of the named option, or the specified default value if the option was not set.List<Float>getFloatOptionValues(String optionName)Returns a list of all the parsed values for the specified option, or an empty list if the option was not set.IntegergetIntegerOptionValue(String optionName)Convenience method to return the parsed value of the named option, or null if the option was not set.IntegergetIntegerOptionValue(String optionName, Integer def)Convenience method to return the parsed value of the named option, or the specified default value if the option was not set.List<Integer>getIntegerOptionValues(String optionName)Returns a list of all the parsed values for the specified option, or an empty list if the option was not set.LocalDategetLocalDateOptionValue(String optionName)Convenience method to return the parsed value of the named option, or null if the option was not set.LocalDategetLocalDateOptionValue(String optionName, LocalDate def)Convenience method to return the parsed value of the named option, or the specified default value if the option was not set.List<LocalDate>getLocalDateOptionValues(String optionName)Returns a list of all the parsed values for the specified option, or an empty list if the option was not set.LonggetLongOptionValue(String optionName)Convenience method to return the parsed value of the named option, or null if the option was not set.LonggetLongOptionValue(String optionName, Long def)Convenience method to return the parsed value of the named option, or the specified default value if the option was not set.List<Long>getLongOptionValues(String optionName)Returns a list of all the parsed values for the specified option, or an empty list if the option was not set.List<String>getNonOptionArguments()Returns a list of the non-option command-line arguments.<T> Option<T>getOption(String optionName, Class<T> type)Returns theOptionwith the specified name (either short or long).List<Option>getOptions()Returns all theOptioninstances registered with the parser.<T> TgetOptionValue(String optionName, Class<T> type)Convenience method to return the parsed value of the named option, or null if the option was not set, equivalent togetOptionValue(optionName, type, null).<T> TgetOptionValue(String optionName, Class<T> type, T def)Convenience method to return the parsed value of the named option, or the specified default value if the option was not set.<T> TgetOptionValue(Option<T> opt)Convenience method to return the parsed value of the specified option, or null if the option was not set.<T> TgetOptionValue(Option<T> opt, T def)Convenience method to return the parsed value of the specified option, or the specified default value if the option was not set.<T> List<T>getOptionValues(String optionName, Class<T> type)Returns a list of all the parsed values for the specified option, or an empty list if the option was not set.<T> List<T>getOptionValues(Option<T> opt)Returns a list of all the parsed values for the specified option, or an empty list if the option was not set.StringgetStringOptionValue(String optionName)Convenience method to return the parsed value of the named option, or null if the option was not set.StringgetStringOptionValue(String optionName, String def)Convenience method to return the parsed value of the named option, or the specified default value if the option was not set.List<String>getStringOptionValues(String optionName)Returns a list of all the parsed values for the specified option, or an empty list if the option was not set.voidparse(String[] args)Extract the option-mapped and unmapped arguments from the given array of command-line arguments, using the specified locale.booleanparsedSolitaryHyphen()Returns whether a single-argument was found.voidprintUsage(PrintStream ps, boolean longUsage)Prints the command-line usage message to the specifiedPrintStream, making a guess at the application launch command.voidprintUsage(PrintStream ps, boolean longUsage, String suffixArgs)Deprecated.Recommend to useprintUsage(PrintStream, boolean, String, String, String)as a replacement to avoid confusion over parameter orderingvoidprintUsage(PrintStream ps, boolean longUsage, String appString, String suffixArgs)Deprecated.Recommend to useprintUsage(PrintStream, boolean, String, String, String)as a replacement to avoid confusion over parameter orderingvoidprintUsage(PrintStream ps, boolean longUsage, String appString, String suffixArgs, String extraInfo)Prints the command-line usage message to the specifiedPrintStream.voidsetHidden(String optionName)Hides the specifiedOptionfrom being printed in the usage message.voidshowLongNamesInShortUsage()Allows overriding default behaviour of only showing short option names in the short automatic usage message.
-
-
-
Constructor Detail
-
CLAParser
public CLAParser(Locale locale)
Creates a newCLAParserinstance, using the default locale.- Parameters:
locale- Locale to use for i18n resources
-
CLAParser
public CLAParser()
Creates a newCLAParserinstance, using the default locale.
-
-
Method Detail
-
showLongNamesInShortUsage
public void showLongNamesInShortUsage()
Allows overriding default behaviour of only showing short option names in the short automatic usage message. Once this method has been called, any long option names are also shown (as in older versions).
-
parsedSolitaryHyphen
public boolean parsedSolitaryHyphen()
Returns whether a single-argument was found. This is typically used to specify that an application should read from STDIN or write to STDOUT. The argument is written to the non-option arguments, so this can be tested independently, but this is just a convenience method to do the same.- Returns:
- true if solitary hyphen was parsed, false otherwise
-
addOption
public <T> Option<T> addOption(Option<T> opt)
Adds the specifiedOptionto the list of those to be parsed from the command-line arguments.- Type Parameters:
T- the return type of the option- Parameters:
opt-Optioninstance to add- Returns:
- the
Optioninstance that was added - Throws:
IllegalArgumentException- if either short/long name of the specifiedOptionis already in use
-
setHidden
public void setHidden(String optionName) throws OptionException
Hides the specifiedOptionfrom being printed in the usage message.- Parameters:
optionName- short/long name of option to "hide"- Throws:
OptionException- if the specified option can't be found
-
addBooleanOption
public Option<Boolean> addBooleanOption(String shortName, String longName, String description, int minCount, int maxCount)
Convenience method to add anOptionof typeBoolean.- Parameters:
shortName- short name of the optionlongName- long name of the optiondescription- helpful description of the option (printed for usage message)minCount- minimum number of occurrences required for this optionmaxCount- maximum number of occurrences required for this option- Returns:
- the new
Optioninstance
-
addBooleanOption
public Option<Boolean> addBooleanOption(String shortName, String longName, String description, boolean allowMany)
Convenience method to add anOptionof typeBoolean.- Parameters:
shortName- short name of the optionlongName- long name of the optiondescription- helpful description of the option (printed for usage message)allowMany- whether this option can take more than one value (i.e. be specified more than once)- Returns:
- the new
Optioninstance
-
addBooleanOption
public Option<Boolean> addBooleanOption(String shortName, String longName, String description, int maxCount)
Convenience method to add anOptionof typeBoolean.- Parameters:
shortName- short name of the optionlongName- long name of the optiondescription- helpful description of the option (printed for usage message)maxCount- maximum number of occurrences required for this option- Returns:
- the new
Optioninstance
-
addBooleanOption
public Option<Boolean> addBooleanOption(String shortName, String longName, String description)
Convenience method to add anOptionof typeBoolean(single value allowed).- Parameters:
shortName- short name of the optionlongName- long name of the optiondescription- helpful description of the option (printed for usage message)- Returns:
- the new
Optioninstance
-
addBooleanOption
public Option<Boolean> addBooleanOption(String shortName, boolean allowMany)
Convenience method to add anOptionof typeBoolean.- Parameters:
shortName- short name of the optionallowMany- whether this option can take more than one value (i.e. be specified more than once)- Returns:
- the new
Optioninstance
-
addBooleanOption
public Option<Boolean> addBooleanOption(String shortName, int maxCount)
Convenience method to add anOptionof typeBoolean.- Parameters:
shortName- short name of the optionmaxCount- maximum number of occurrences required for this option- Returns:
- the new
Optioninstance
-
addBooleanOption
public Option<Boolean> addBooleanOption(String shortName)
Convenience method to add anOptionof typeBoolean(single value allowed).- Parameters:
shortName- short name of the option- Returns:
- the new
Optioninstance
-
addIntegerOption
public Option<Integer> addIntegerOption(String shortName, String longName, String description, boolean mandatory, boolean allowMany)
Convenience method to add anOptionof typeInteger.- Parameters:
shortName- short name of the optionlongName- long name of the optiondescription- helpful description of the option (printed for usage message)mandatory- whether this option must be specifiedallowMany- whether this option can take more than one value (i.e. be specified more than once)- Returns:
- the new
Optioninstance
-
addIntegerOption
public Option<Integer> addIntegerOption(String shortName, String longName, String description, int minCount, int maxCount)
Convenience method to add anOptionof typeInteger.- Parameters:
shortName- short name of the optionlongName- long name of the optiondescription- helpful description of the option (printed for usage message)minCount- minimum number of occurrences required for this optionmaxCount- maximum number of occurrences required for this option- Returns:
- the new
Optioninstance
-
addIntegerOption
public Option<Integer> addIntegerOption(String shortName, boolean mandatory, boolean allowMany)
Convenience method to add anOptionof typeInteger.- Parameters:
shortName- short name of the optionmandatory- whether this option must be specifiedallowMany- whether this option can take more than one value (i.e. be specified more than once)- Returns:
- the new
Optioninstance
-
addIntegerOption
public Option<Integer> addIntegerOption(String shortName, int minCount, int maxCount)
Convenience method to add anOptionof typeInteger.- Parameters:
shortName- short name of the optionminCount- minimum number of occurrences required for this optionmaxCount- maximum number of occurrences required for this option- Returns:
- the new
Optioninstance
-
addLongOption
public Option<Long> addLongOption(String shortName, String longName, String description, boolean mandatory, boolean allowMany)
Convenience method to add anOptionof typeLong.- Parameters:
shortName- short name of the optionlongName- long name of the optiondescription- helpful description of the option (printed for usage message)mandatory- whether this option must be specifiedallowMany- whether this option can take more than one value (i.e. be specified more than once)- Returns:
- the new
Optioninstance
-
addLongOption
public Option<Long> addLongOption(String shortName, String longName, String description, int minCount, int maxCount)
Convenience method to add anOptionof typeLong.- Parameters:
shortName- short name of the optionlongName- long name of the optiondescription- helpful description of the option (printed for usage message)minCount- minimum number of occurrences required for this optionmaxCount- maximum number of occurrences required for this option- Returns:
- the new
Optioninstance
-
addLongOption
public Option<Long> addLongOption(String shortName, boolean mandatory, boolean allowMany)
Convenience method to add anOptionof typeLong.- Parameters:
shortName- short name of the optionmandatory- whether this option must be specifiedallowMany- whether this option can take more than one value (i.e. be specified more than once)- Returns:
- the new
Optioninstance
-
addLongOption
public Option<Long> addLongOption(String shortName, int minCount, int maxCount)
Convenience method to add anOptionof typeLong.- Parameters:
shortName- short name of the optionminCount- minimum number of occurrences required for this optionmaxCount- maximum number of occurrences required for this option- Returns:
- the new
Optioninstance
-
addDoubleOption
public Option<Double> addDoubleOption(String shortName, String longName, String description, boolean mandatory, boolean allowMany)
Convenience method to add anOptionof typeDouble.- Parameters:
shortName- short name of the optionlongName- long name of the optiondescription- helpful description of the option (printed for usage message)mandatory- whether this option must be specifiedallowMany- whether this option can take more than one value (i.e. be specified more than once)- Returns:
- the new
Optioninstance
-
addDoubleOption
public Option<Double> addDoubleOption(String shortName, String longName, String description, int minCount, int maxCount)
Convenience method to add anOptionof typeDouble.- Parameters:
shortName- short name of the optionlongName- long name of the optiondescription- helpful description of the option (printed for usage message)minCount- minimum number of occurrences required for this optionmaxCount- maximum number of occurrences required for this option- Returns:
- the new
Optioninstance
-
addDoubleOption
public Option<Double> addDoubleOption(String shortName, boolean mandatory, boolean allowMany)
Convenience method to add anOptionof typeDouble.- Parameters:
shortName- short name of the optionmandatory- whether this option must be specifiedallowMany- whether this option can take more than one value (i.e. be specified more than once)- Returns:
- the new
Optioninstance
-
addDoubleOption
public Option<Double> addDoubleOption(String shortName, int minCount, int maxCount)
Convenience method to add anOptionof typeDouble.- Parameters:
shortName- short name of the optionminCount- minimum number of occurrences required for this optionmaxCount- maximum number of occurrences required for this option- Returns:
- the new
Optioninstance
-
addFloatOption
public Option<Float> addFloatOption(String shortName, String longName, String description, boolean mandatory, boolean allowMany)
Convenience method to add anOptionof typeFloat.- Parameters:
shortName- short name of the optionlongName- long name of the optiondescription- helpful description of the option (printed for usage message)mandatory- whether this option must be specifiedallowMany- whether this option can take more than one value (i.e. be specified more than once)- Returns:
- the new
Optioninstance
-
addFloatOption
public Option<Float> addFloatOption(String shortName, String longName, String description, int minCount, int maxCount)
Convenience method to add anOptionof typeFloat.- Parameters:
shortName- short name of the optionlongName- long name of the optiondescription- helpful description of the option (printed for usage message)minCount- minimum number of occurrences required for this optionmaxCount- maximum number of occurrences required for this option- Returns:
- the new
Optioninstance
-
addFloatOption
public Option<Float> addFloatOption(String shortName, boolean mandatory, boolean allowMany)
Convenience method to add anOptionof typeFloat.- Parameters:
shortName- short name of the optionmandatory- whether this option must be specifiedallowMany- whether this option can take more than one value (i.e. be specified more than once)- Returns:
- the new
Optioninstance
-
addFloatOption
public Option<Float> addFloatOption(String shortName, int minCount, int maxCount)
Convenience method to add anOptionof typeFloat.- Parameters:
shortName- short name of the optionminCount- minimum number of occurrences required for this optionmaxCount- maximum number of occurrences required for this option- Returns:
- the new
Optioninstance
-
addStringOption
public Option<String> addStringOption(String shortName, String longName, String description, boolean mandatory, boolean allowMany)
Convenience method to add anOptionof typeString.- Parameters:
shortName- short name of the optionlongName- long name of the optiondescription- helpful description of the option (printed for usage message)mandatory- whether this option must be specifiedallowMany- whether this option can take more than one value (i.e. be specified more than once)- Returns:
- the new
Optioninstance
-
addStringOption
public Option<String> addStringOption(String shortName, String longName, String description, int minCount, int maxCount)
Convenience method to add anOptionof typeString.- Parameters:
shortName- short name of the optionlongName- long name of the optiondescription- helpful description of the option (printed for usage message)minCount- minimum number of occurrences required for this optionmaxCount- maximum number of occurrences required for this option- Returns:
- the new
Optioninstance
-
addStringOption
public Option<String> addStringOption(String shortName, String longName, String description)
Convenience method to add anOptionof typeString(single value allowed, non-mandatory).- Parameters:
shortName- short name of the optionlongName- long name of the optiondescription- helpful description of the option (printed for usage message)- Returns:
- the new
Optioninstance
-
addStringOption
public Option<String> addStringOption(String shortName, boolean mandatory, boolean allowMany)
Convenience method to add anOptionof typeString(no long name, no description).- Parameters:
shortName- short name of the optionmandatory- whether this option must be specifiedallowMany- whether this option can take more than one value (i.e. be specified more than once)- Returns:
- the new
Optioninstance
-
addStringOption
public Option<String> addStringOption(String shortName, int minCount, int maxCount)
Convenience method to add anOptionof typeString(no long name, no description).- Parameters:
shortName- short name of the optionminCount- minimum number of occurrences required for this optionmaxCount- maximum number of occurrences required for this option- Returns:
- the new
Optioninstance
-
addFileOption
public Option<String> addFileOption(String shortName, String longName, String description, boolean mandatory, boolean allowMany)
Convenience method to add anOptionof typeStringwhich refers to a file/folder. For example, use this method to:- Allow specification of a existing or new file/folder.
- Parameters:
shortName- short name of the optionlongName- long name of the optiondescription- helpful description of the option (printed for usage message)mandatory- whether this option must be specifiedallowMany- whether this option can take more than one value (i.e. be specified more than once)- Returns:
- the new
Optioninstance
-
addFileNewOption
public Option<String> addFileNewOption(String shortName, String longName, String description, boolean mandatory, boolean allowMany)
Convenience method to add anOptionof typeStringwhich refers to a new or existing file/folder.- Parameters:
shortName- short name of the optionlongName- long name of the optiondescription- helpful description of the option (printed for usage message)mandatory- whether this option must be specifiedallowMany- whether this option can take more than one value (i.e. be specified more than once)- Returns:
- the new
Optioninstance
-
addFileExistingOption
public Option<String> addFileExistingOption(String shortName, String longName, String description, int minCount, int maxCount)
Convenience method to add anOptionof typeStringwhich refers to an existing file (which is not a folder). For example, use this method to:- Enforce specification of an existing file (which is not a folder)
- Parameters:
shortName- short name of the optionlongName- long name of the optiondescription- helpful description of the option (printed for usage message)minCount- minimum number of occurrences required for this optionmaxCount- maximum number of occurrences required for this option- Returns:
- the new
Optioninstance
-
addFileExistingOption
public Option<String> addFileExistingOption(String shortName, String longName, String description, boolean mandatory, boolean allowMany)
Convenience method to add anOptionof typeStringwhich refers to an existing file (which is not a folder). For example, use this method to:- Enforce specification of an existing file (which is not a folder)
- Parameters:
shortName- short name of the optionlongName- long name of the optiondescription- helpful description of the option (printed for usage message)mandatory- whether this option must be specifiedallowMany- whether this option can take more than one value (i.e. be specified more than once)- Returns:
- the new
Optioninstance
-
addDirectoryExistingOption
public Option<String> addDirectoryExistingOption(String shortName, String longName, String description, int minCount, int maxCount)
Convenience method to add anOptionof typeStringwhich refers to an existing folder. For example, use this method to enforce specification of an existing folder. To allow specification of a new folder (one that does not yet exist), use theaddFileOption()method instead.- Parameters:
shortName- short name of the optionlongName- long name of the optiondescription- helpful description of the option (printed for usage message)minCount- minimum number of occurrences required for this optionmaxCount- maximum number of occurrences required for this option- Returns:
- the new
Optioninstance
-
addFolderExistingOption
@Deprecated public Option<String> addFolderExistingOption(String shortName, String longName, String description, int minCount, int maxCount)
Deprecated.- Parameters:
shortName- short name of the optionlongName- long name of the optiondescription- helpful description of the option (printed for usage message)minCount- minimum number of occurrences required for this optionmaxCount- maximum number of occurrences required for this option- Returns:
- the new
Optioninstance
-
addDirectoryExistingOption
public Option<String> addDirectoryExistingOption(String shortName, String longName, String description, boolean mandatory, boolean allowMany)
Convenience method to add anOptionof typeStringwhich refers to an existing folder. For example, use this method to enforce specification of an existing folder. To allow specification of a new folder (one that does not yet exist), use theaddFileOption()method instead.- Parameters:
shortName- short name of the optionlongName- long name of the optiondescription- helpful description of the option (printed for usage message)mandatory- whether this option must be specifiedallowMany- whether this option can take more than one value (i.e. be specified more than once)- Returns:
- the new
Optioninstance
-
addFolderExistingOption
@Deprecated public Option<String> addFolderExistingOption(String shortName, String longName, String description, boolean mandatory, boolean allowMany)
Deprecated.- Parameters:
shortName- short name of the optionlongName- long name of the optiondescription- helpful description of the option (printed for usage message)mandatory- whether this option must be specifiedallowMany- whether this option can take more than one value (i.e. be specified more than once)- Returns:
- the new
Optioninstance
-
addEnumStringOption
public Option<String> addEnumStringOption(String shortName, String longName, String description, boolean mandatory, boolean allowMany, String[] allowedValues, boolean ignoreCase)
Convenience method to add anOptionof enumeratedStringtype.- Parameters:
shortName- short name of the optionlongName- long name of the optiondescription- helpful description of the option (printed for usage message)mandatory- whether this option must be specifiedallowMany- whether this option can take more than one value (i.e. be specified more than once)allowedValues- array of string values allowed by this enumerated optionignoreCase- whether to ignore the case of string values- Returns:
- the new
Optioninstance
-
addEnumStringOption
public Option<String> addEnumStringOption(String shortName, String longName, String description, int minCount, int maxCount, String[] allowedValues, boolean ignoreCase)
Convenience method to add anOptionof enumeratedStringtype.- Parameters:
shortName- short name of the optionlongName- long name of the optiondescription- helpful description of the option (printed for usage message)minCount- minimum number of occurrences required for this optionmaxCount- maximum number of occurrences required for this optionallowedValues- array of string values allowed by this enumerated optionignoreCase- whether to ignore the case of string values- Returns:
- the new
Optioninstance
-
addEnumStringOption
public Option<String> addEnumStringOption(String shortName, String longName, String description, boolean mandatory, boolean allowMany, String[] allowedValues)
Convenience method to add anOptionof enumeratedStringtype (case-insensitive string matching).- Parameters:
shortName- short name of the optionlongName- long name of the optiondescription- helpful description of the option (printed for usage message)mandatory- whether this option must be specifiedallowMany- whether this option can take more than one value (i.e. be specified more than once)allowedValues- array of string values allowed by this enumerated option- Returns:
- the new
Optioninstance
-
addEnumStringOption
public Option<String> addEnumStringOption(String shortName, String longName, String description, String[] allowedValues)
Convenience method to add anOptionof enumeratedStringtype (single value allowed, non-mandatory).- Parameters:
shortName- short name of the optionlongName- long name of the optiondescription- helpful description of the option (printed for usage message)allowedValues- array of string values allowed by this enumerated option- Returns:
- the new
Optioninstance
-
addEnumIntegerOption
public Option<Integer> addEnumIntegerOption(String shortName, String longName, String description, boolean mandatory, boolean allowMany, int[] allowedValues)
Convenience method to add anOptionof enumeratedIntegertype.- Parameters:
shortName- short name of the optionlongName- long name of the optiondescription- helpful description of the option (printed for usage message)mandatory- whether this option must be specifiedallowMany- whether this option can take more than one value (i.e. be specified more than once)allowedValues- array of string values allowed by this enumerated option- Returns:
- the new
Optioninstance
-
addEnumIntegerOption
public Option<Integer> addEnumIntegerOption(String shortName, String longName, String description, int[] allowedValues)
Convenience method to add anOptionof enumeratedIntegertype (single value allowed, non-mandatory).- Parameters:
shortName- short name of the optionlongName- long name of the optiondescription- helpful description of the option (printed for usage message)allowedValues- array of string values allowed by this enumerated option- Returns:
- the new
Optioninstance
-
addLocalDateOption
public Option<LocalDate> addLocalDateOption(String shortName, String longName, String description, boolean mandatory, boolean allowMany)
Convenience method to add anOptionof typeLocalDate.- Parameters:
shortName- short name of the optionlongName- long name of the optiondescription- helpful description of the option (printed for usage message)mandatory- whether this option must be specifiedallowMany- whether this option can take more than one value (i.e. be specified more than once)- Returns:
- the new
Optioninstance
-
addLocalDateOption
public Option<LocalDate> addLocalDateOption(String shortName, String longName, String description, int minCount, int maxCount)
Convenience method to add anOptionof typeLocalDate.- Parameters:
shortName- short name of the optionlongName- long name of the optiondescription- helpful description of the option (printed for usage message)minCount- minimum number of occurrences required for this optionmaxCount- maximum number of occurrences required for this option- Returns:
- the new
Optioninstance
-
addLocalDateOption
public Option<LocalDate> addLocalDateOption(String shortName, String longName, String description)
Convenience method to add anOptionof typeLocalDate(single value allowed, non-mandatory).- Parameters:
shortName- short name of the optionlongName- long name of the optiondescription- helpful description of the option (printed for usage message)- Returns:
- the new
Optioninstance
-
addLocalDateOption
public Option<LocalDate> addLocalDateOption(String shortName, boolean mandatory, boolean allowMany)
Convenience method to add anOptionof typeLocalDate(no long name, no description).- Parameters:
shortName- short name of the optionmandatory- whether this option must be specifiedallowMany- whether this option can take more than one value (i.e. be specified more than once)- Returns:
- the new
Optioninstance
-
addLocalDateOption
public Option<LocalDate> addLocalDateOption(String shortName, int minCount, int maxCount)
Convenience method to add anOptionof typeLocalDate(no long name, no description).- Parameters:
shortName- short name of the optionminCount- minimum number of occurrences required for this optionmaxCount- maximum number of occurrences required for this option- Returns:
- the new
Optioninstance
-
getOption
public <T> Option<T> getOption(String optionName, Class<T> type) throws OptionException
Returns theOptionwith the specified name (either short or long).- Type Parameters:
T- the return type of the option- Parameters:
optionName- option name for which to get value (either short/long)type- class type for option value compatibility check- Returns:
- Option instance
- Throws:
OptionException- ifoptionNameis null, cannot be found, or is of the wrong type
-
getOptions
public List<Option> getOptions()
Returns all theOptioninstances registered with the parser.- Returns:
- list of options
-
getOptionValues
public <T> List<T> getOptionValues(Option<T> opt) throws OptionException
Returns a list of all the parsed values for the specified option, or an empty list if the option was not set.- Type Parameters:
T- the return type of the option- Parameters:
opt- option for which to get values- Returns:
- A list of all the parsed values for the specified option, or an empty list if the option was not set.
- Throws:
OptionException- ifoptis null, cannot be found, or is of the wrong type
-
getOptionValues
public <T> List<T> getOptionValues(String optionName, Class<T> type) throws OptionException
Returns a list of all the parsed values for the specified option, or an empty list if the option was not set. This method performs type-checking of theOption.- Type Parameters:
T- the return type of the option- Parameters:
optionName- option name for which to get value (either short/long)type- class type for option value compatibility check- Returns:
- list of option values
- Throws:
OptionException- ifoptionNameis null, cannot be found, or is of the wrong type
-
getOptionValue
public <T> T getOptionValue(Option<T> opt) throws OptionException
Convenience method to return the parsed value of the specified option, or null if the option was not set. This method is only usable with options that cannot take multiple values.- Type Parameters:
T- the return type of the option- Parameters:
opt- option for which to get value- Returns:
- option value
- Throws:
OptionException- ifoptis null, cannot be found, or is of the wrong type
-
getOptionValue
public <T> T getOptionValue(Option<T> opt, T def) throws OptionException
Convenience method to return the parsed value of the specified option, or the specified default value if the option was not set. This method is only usable with options that cannot take multiple values.- Type Parameters:
T- the return type of the option- Parameters:
opt- option for which to get valuedef- default value to use if the option was not set- Returns:
- option value
- Throws:
OptionException- ifoptis null, cannot be found, or is of the wrong type
-
getOptionValue
public <T> T getOptionValue(String optionName, Class<T> type, T def) throws OptionException
Convenience method to return the parsed value of the named option, or the specified default value if the option was not set. This method should only be used with typed options that cannot take multiple values.- Type Parameters:
T- the return type of the option- Parameters:
optionName- name of the optiontype- class type for option value compatibility checkdef- default value to use if the option was not set- Returns:
- option value, or default value if option is unset
- Throws:
OptionException- ifoptionNameis null, cannot be found, or is of the wrong type
-
getOptionValue
public <T> T getOptionValue(String optionName, Class<T> type) throws OptionException
Convenience method to return the parsed value of the named option, or null if the option was not set, equivalent togetOptionValue(optionName, type, null). This method should only be used with typed options that cannot take multiple values.- Type Parameters:
T- the return type of the option- Parameters:
optionName- name of the optiontype- class type for option value compatibility check- Returns:
- option value
- Throws:
OptionException- ifoptionNameis null, cannot be found, or is of the wrong type
-
getBooleanOptionValues
public List<Boolean> getBooleanOptionValues(String optionName) throws OptionException
Returns a list of all the parsed values for the specified option, or an empty list if the option was not set.- Parameters:
optionName- name of the option- Returns:
- list of option values
- Throws:
OptionException- ifoptionNameis null, cannot be found, or is of the wrong type
-
getBooleanOptionValue
public Boolean getBooleanOptionValue(String optionName, Boolean def) throws OptionException
Convenience method to return the parsed value of the named option, or the specified default value if the option was not set. This method should only be used with options that cannot take multiple values.- Parameters:
optionName- name of the optiondef- default value to use if the option was not set- Returns:
- option value, or default value if option is unset
- Throws:
OptionException- ifoptionNameis null, cannot be found, or is of the wrong type
-
getBooleanOptionValue
public Boolean getBooleanOptionValue(String optionName) throws OptionException
Convenience method to return the parsed value of the named option, orfalseif the option was not set. This method should only be used with options that cannot take multiple values. NOTE: this method operates slightly differently compared to the othergetXOptionValue(String)methods, in that when the option is not defined, it returnedBoolean.FALSEinstead ofnull.- Parameters:
optionName- name of the option- Returns:
- option value, or null if option is unset
- Throws:
OptionException- ifoptionNameis null, cannot be found, or is of the wrong type
-
getIntegerOptionValues
public List<Integer> getIntegerOptionValues(String optionName) throws OptionException
Returns a list of all the parsed values for the specified option, or an empty list if the option was not set.- Parameters:
optionName- name of the option- Returns:
- list of option values
- Throws:
OptionException- ifoptionNameis null, cannot be found, or is of the wrong type
-
getIntegerOptionValue
public Integer getIntegerOptionValue(String optionName, Integer def) throws OptionException
Convenience method to return the parsed value of the named option, or the specified default value if the option was not set. This method should only be used with options that cannot take multiple values.- Parameters:
optionName- name of the optiondef- default value to use if the option was not set- Returns:
- option value, or default value if option is unset
- Throws:
OptionException- ifoptionNameis null, cannot be found, or is of the wrong type
-
getIntegerOptionValue
public Integer getIntegerOptionValue(String optionName) throws OptionException
Convenience method to return the parsed value of the named option, or null if the option was not set. This method should only be used with options that cannot take multiple values.- Parameters:
optionName- name of the option- Returns:
- option value, or null if option is unset
- Throws:
OptionException- ifoptionNameis null, cannot be found, or is of the wrong type
-
getLongOptionValues
public List<Long> getLongOptionValues(String optionName) throws OptionException
Returns a list of all the parsed values for the specified option, or an empty list if the option was not set.- Parameters:
optionName- name of the option- Returns:
- list of option values
- Throws:
OptionException- ifoptionNameis null, cannot be found, or is of the wrong type
-
getLongOptionValue
public Long getLongOptionValue(String optionName, Long def) throws OptionException
Convenience method to return the parsed value of the named option, or the specified default value if the option was not set. This method should only be used with options that cannot take multiple values.- Parameters:
optionName- name of the optiondef- default value to use if the option was not set- Returns:
- option value, or default value if option is unset
- Throws:
OptionException- ifoptionNameis null, cannot be found, or is of the wrong type
-
getLongOptionValue
public Long getLongOptionValue(String optionName) throws OptionException
Convenience method to return the parsed value of the named option, or null if the option was not set. This method should only be used with options that cannot take multiple values.- Parameters:
optionName- name of the option- Returns:
- option value, or null if option is unset
- Throws:
OptionException- ifoptionNameis null, cannot be found, or is of the wrong type
-
getDoubleOptionValues
public List<Double> getDoubleOptionValues(String optionName) throws OptionException
Returns a list of all the parsed values for the specified option, or an empty list if the option was not set.- Parameters:
optionName- name of the option- Returns:
- list of option values
- Throws:
OptionException- ifoptionNameis null, cannot be found, or is of the wrong type
-
getDoubleOptionValue
public Double getDoubleOptionValue(String optionName, Double def) throws OptionException
Convenience method to return the parsed value of the named option, or the specified default value if the option was not set. This method should only be used with options that cannot take multiple values.- Parameters:
optionName- name of the optiondef- default value to use if the option was not set- Returns:
- option value, or default value if option is unset
- Throws:
OptionException- ifoptionNameis null, cannot be found, or is of the wrong type
-
getDoubleOptionValue
public Double getDoubleOptionValue(String optionName) throws OptionException
Convenience method to return the parsed value of the named option, or null if the option was not set. This method should only be used with options that cannot take multiple values.- Parameters:
optionName- name of the option- Returns:
- option value, or null if option is unset
- Throws:
OptionException- ifoptionNameis null, cannot be found, or is of the wrong type
-
getFloatOptionValues
public List<Float> getFloatOptionValues(String optionName) throws OptionException
Returns a list of all the parsed values for the specified option, or an empty list if the option was not set.- Parameters:
optionName- name of the option- Returns:
- list of option values
- Throws:
OptionException- ifoptionNameis null, cannot be found, or is of the wrong type
-
getFloatOptionValue
public Float getFloatOptionValue(String optionName, Float def) throws OptionException
Convenience method to return the parsed value of the named option, or the specified default value if the option was not set. This method should only be used with options that cannot take multiple values.- Parameters:
optionName- name of the optiondef- default value to use if the option was not set- Returns:
- option value, or default value if option is unset
- Throws:
OptionException- ifoptionNameis null, cannot be found, or is of the wrong type
-
getFloatOptionValue
public Float getFloatOptionValue(String optionName) throws OptionException
Convenience method to return the parsed value of the named option, or null if the option was not set. This method should only be used with options that cannot take multiple values.- Parameters:
optionName- name of the option- Returns:
- option value, or null if option is unset
- Throws:
OptionException- ifoptionNameis null, cannot be found, or is of the wrong type
-
getStringOptionValues
public List<String> getStringOptionValues(String optionName) throws OptionException
Returns a list of all the parsed values for the specified option, or an empty list if the option was not set.- Parameters:
optionName- name of the option- Returns:
- list of option values
- Throws:
OptionException- ifoptionNameis null, cannot be found, or is of the wrong type
-
getStringOptionValue
public String getStringOptionValue(String optionName, String def) throws OptionException
Convenience method to return the parsed value of the named option, or the specified default value if the option was not set. This method should only be used with options that cannot take multiple values.- Parameters:
optionName- name of the optiondef- default value to use if the option was not set- Returns:
- option value, or default value if option is unset
- Throws:
OptionException- ifoptionNameis null, cannot be found, or is of the wrong type
-
getStringOptionValue
public String getStringOptionValue(String optionName) throws OptionException
Convenience method to return the parsed value of the named option, or null if the option was not set. This method should only be used with options that cannot take multiple values.- Parameters:
optionName- name of the option- Returns:
- option value, or null if option is unset
- Throws:
OptionException- ifoptionNameis null, cannot be found, or is of the wrong type
-
getLocalDateOptionValues
public List<LocalDate> getLocalDateOptionValues(String optionName) throws OptionException
Returns a list of all the parsed values for the specified option, or an empty list if the option was not set.- Parameters:
optionName- name of the option- Returns:
- list of option values
- Throws:
OptionException- ifoptionNameis null, cannot be found, or is of the wrong type
-
getLocalDateOptionValue
public LocalDate getLocalDateOptionValue(String optionName, LocalDate def) throws OptionException
Convenience method to return the parsed value of the named option, or the specified default value if the option was not set. This method should only be used with options that cannot take multiple values.- Parameters:
optionName- name of the optiondef- default value to use if the option was not set- Returns:
- option value, or default value if option is unset
- Throws:
OptionException- ifoptionNameis null, cannot be found, or is of the wrong type
-
getLocalDateOptionValue
public LocalDate getLocalDateOptionValue(String optionName) throws OptionException
Convenience method to return the parsed value of the named option, or null if the option was not set. This method should only be used with options that cannot take multiple values.- Parameters:
optionName- name of the option- Returns:
- option value, or null if option is unset
- Throws:
OptionException- ifoptionNameis null, cannot be found, or is of the wrong type
-
getFileOptionValues
public List<File> getFileOptionValues(String optionName) throws OptionException
Returns a list of all the parsed values for the specified option, or an empty list if the option was not set.- Parameters:
optionName- name of the option- Returns:
- list of option values
- Throws:
OptionException- ifoptionNameis null, cannot be found, or is of the wrong type
-
getFileOptionValue
public File getFileOptionValue(String optionName, File def) throws OptionException
Convenience method to return the parsed value of the named option, or the specified default value if the option was not set. This method should only be used with options that cannot take multiple values.- Parameters:
optionName- name of the optiondef- default value to use if the option was not set- Returns:
- option value, or default value if option is unset
- Throws:
OptionException- ifoptionNameis null, cannot be found, or is of the wrong type
-
getFileOptionValue
public File getFileOptionValue(String optionName) throws OptionException
Convenience method to return the parsed value of the named option, or null if the option was not set. This method should only be used with options that cannot take multiple values.- Parameters:
optionName- name of the option- Returns:
- option value, or null if option is unset
- Throws:
OptionException- ifoptionNameis null, cannot be found, or is of the wrong type
-
getNonOptionArguments
public List<String> getNonOptionArguments()
Returns a list of the non-option command-line arguments. Note that this list includes all arguments that are not related to options, and as a result may include "orphan" arguments (in between correctly specified options) in addition to the expected arguments that are specified after all the options.For example:
java DemoApp -i 10 -f 1.2 foo -s bar fu barfor an application with value-taking options
i/f/s, would return [foo,fu,bar] from this method.- Returns:
- A list of the command-line string arguments that were not parsed as options.
-
parse
public void parse(String[] args) throws OptionException
Extract the option-mapped and unmapped arguments from the given array of command-line arguments, using the specified locale.- Parameters:
args- command-line arguments (as passed intomainmethod)- Throws:
OptionException- if an problem is encountered parsing the specified arguments
-
printUsage
public void printUsage(PrintStream ps, boolean longUsage)
Prints the command-line usage message to the specifiedPrintStream, making a guess at the application launch command. The usage message is automatically created using the options specified. The usage can be displayed in either short or long versions, although the long version uses the options' description fields, which are not required, but should generally be included if intending to print the long usage.This is equivalent to calling
printUsage(ps, longUsage, null, null, null).- Parameters:
ps-PrintStreamto which to print usage messagelongUsage- whether to print long version of usage message (otherwise print short version)
-
printUsage
@Deprecated public void printUsage(PrintStream ps, boolean longUsage, String suffixArgs)
Deprecated.Recommend to useprintUsage(PrintStream, boolean, String, String, String)as a replacement to avoid confusion over parameter orderingEquivalent to:printUsage(ps, longUsage, null, suffixArgs, null).- Parameters:
ps-PrintStreamto which to print usage messagelongUsage- whether to print long version of usage message (otherwise print short version)suffixArgs- usage suffix string for defining extra arguments
-
printUsage
@Deprecated public void printUsage(PrintStream ps, boolean longUsage, String appString, String suffixArgs)
Deprecated.Recommend to useprintUsage(PrintStream, boolean, String, String, String)as a replacement to avoid confusion over parameter orderingEquivalent to:printUsage(ps, longUsage, appString, suffixArgs, null).- Parameters:
ps-PrintStreamto which to print usage messagelongUsage- whether to print long version of usage message (otherwise print short version)appString- usage prefix string describing how application is launched;nullspecifies to create value automatically (e.g. "java foo.bar.AppName")suffixArgs- usage suffix string for defining extra arguments
-
printUsage
public void printUsage(PrintStream ps, boolean longUsage, String appString, String suffixArgs, String extraInfo)
Prints the command-line usage message to the specifiedPrintStream. The usage message is automatically created using the options specified. The usage can be displayed in either short or long versions, although the long version uses the options' description fields, which are not required, but should generally be included if intending to print the long usage.- Parameters:
ps-PrintStreamto which to print usage messagelongUsage- whether to print long version of usage message (otherwise print short version)appString- usage prefix string describing how application is launched;nullspecifies to create value automatically (e.g. "java foo.bar.AppName")suffixArgs- usage suffix string for defining extra argumentsextraInfo- additional information to be displayed before options (only whenlongUsageis true)
-
-