public interface OptionDeclarer
OptionDeclarer as a facade, forwarding calls to an
OptionParser instance.
Note that although this is an interface, the returned values of calls are concrete jopt-simple classes.OptionParser| Modifier and Type | Method and Description |
|---|---|
OptionSpecBuilder |
accepts(String option)
Tells the parser to recognize the given option.
|
OptionSpecBuilder |
accepts(String option,
String description)
Tells the parser to recognize the given option.
|
OptionSpecBuilder |
acceptsAll(List<String> options)
Tells the parser to recognize the given options, and treat them as synonymous.
|
OptionSpecBuilder |
acceptsAll(List<String> options,
String description)
Tells the parser to recognize the given options, and treat them as synonymous.
|
void |
allowsUnrecognizedOptions()
Tells the parser to treat unrecognized options as non-option arguments.
|
NonOptionArgumentSpec<String> |
nonOptions()
Gives an object that represents an access point for non-option arguments on a command line.
|
NonOptionArgumentSpec<String> |
nonOptions(String description)
Gives an object that represents an access point for non-option arguments on a command line.
|
void |
posixlyCorrect(boolean setting)
Tells the parser whether or not to behave "POSIX-ly correct"-ly.
|
void |
recognizeAlternativeLongOptions(boolean recognize)
Tells the parser either to recognize or ignore
-W-style long options. |
OptionSpecBuilder accepts(String option)
This method returns an instance of OptionSpecBuilder to allow the formation of parser directives
as sentences in a fluent interface language. For example:
OptionDeclarer parser = new OptionParser();
parser.accepts( "c" ).withRequiredArg().ofType( Integer.class );
If no methods are invoked on the returned OptionSpecBuilder, then the parser treats the option as
accepting no argument.
option - the option to recognizeOptionException - if the option contains illegal charactersNullPointerException - if the option is nullOptionSpecBuilder accepts(String option, String description)
option - the option to recognizedescription - a string that describes the purpose of the option. This is used when generating help
information about the parser.OptionException - if the option contains illegal charactersNullPointerException - if the option is nullaccepts(String)OptionSpecBuilder acceptsAll(List<String> options)
options - the options to recognize and treat as synonymousOptionException - if any of the options contain illegal charactersNullPointerException - if the option list or any of its elements are nullaccepts(String)OptionSpecBuilder acceptsAll(List<String> options, String description)
options - the options to recognize and treat as synonymousdescription - a string that describes the purpose of the option. This is used when generating help
information about the parser.OptionException - if any of the options contain illegal charactersNullPointerException - if the option list or any of its elements are nullIllegalArgumentException - if the option list is emptyacceptsAll(List)NonOptionArgumentSpec<String> nonOptions()
NonOptionArgumentSpec<String> nonOptions(String description)
description - a string that describes the purpose of the non-option arguments. This is used when generating
help information about the parser.nonOptions()void posixlyCorrect(boolean setting)
setting - true if the parser should behave "POSIX-ly correct"-lyvoid allowsUnrecognizedOptions()
Tells the parser to treat unrecognized options as non-option arguments.
If not called, then the parser raises an OptionException when it encounters an unrecognized
option.
void recognizeAlternativeLongOptions(boolean recognize)
-W-style long options.recognize - true if the parser is to recognize the special style of long optionsCopyright © 2017. All Rights Reserved.