public class Options<O extends OptionsBase>
extends java.lang.Object
parse(Class, String...)
method in this class has no clear
use case. Instead, use the OptionsParser
class directly, as in this
code snippet:
OptionsParser parser = OptionsParser.newOptionsParser(FooOptions.class); try { parser.parse(FooOptions.class, args); } catch (OptionsParsingException e) { System.err.print("Error parsing options: " + e.getMessage()); System.err.print(options.getUsage()); System.exit(1); } FooOptions foo = parser.getOptions(FooOptions.class); List<String> otherArguments = parser.getResidue();Using this class in this case actually results in more code.
Modifier and Type | Method and Description |
---|---|
static <O extends OptionsBase> |
getDefaults(java.lang.Class<O> optionsClass)
Returns an options object at its default values.
|
O |
getOptions()
Returns an instance of options class O.
|
java.lang.String[] |
getRemainingArgs()
Returns the arguments that we didn't parse.
|
static java.lang.String |
getUsage(java.lang.Class<? extends OptionsBase> optionsClass)
Returns a usage string (renders the help information, the defaults, and
of course the option names).
|
static <O extends OptionsBase> |
parse(java.lang.Class<O> optionsClass,
java.lang.String... args)
Parse the options provided in args, given the specification in
optionsClass.
|
public static <O extends OptionsBase> Options<O> parse(java.lang.Class<O> optionsClass, java.lang.String... args) throws OptionsParsingException
OptionsParsingException
public static <O extends OptionsBase> O getDefaults(java.lang.Class<O> optionsClass)
public static java.lang.String getUsage(java.lang.Class<? extends OptionsBase> optionsClass)
public O getOptions()
public java.lang.String[] getRemainingArgs()