Package joptsimple
Interface OptionDeclarer
- All Known Implementing Classes:
OptionParser
public interface OptionDeclarer
Trains the option parser. This interface aids integration that disposes declaration of options but not actual
command-line parsing.
Typical use is for another class to implement
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.- Since:
- 4.6
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionTells the parser to recognize the given option.Tells the parser to recognize the given option.acceptsAll
(List<String> options) Tells the parser to recognize the given options, and treat them as synonymous.acceptsAll
(List<String> options, String description) Tells the parser to recognize the given options, and treat them as synonymous.void
Tells the parser to treat unrecognized options as non-option arguments.Gives an object that represents an access point for non-option arguments on a command line.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.
-
Method Details
-
accepts
Tells the parser to recognize the given 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.- Parameters:
option
- the option to recognize- Returns:
- an object that can be used to flesh out more detail about the option
- Throws:
OptionException
- if the option contains illegal charactersNullPointerException
- if the option isnull
-
accepts
Tells the parser to recognize the given option.- Parameters:
option
- the option to recognizedescription
- a string that describes the purpose of the option. This is used when generating help information about the parser.- Returns:
- an object that can be used to flesh out more detail about the option
- Throws:
OptionException
- if the option contains illegal charactersNullPointerException
- if the option isnull
- See Also:
-
acceptsAll
Tells the parser to recognize the given options, and treat them as synonymous.- Parameters:
options
- the options to recognize and treat as synonymous- Returns:
- an object that can be used to flesh out more detail about the options
- Throws:
OptionException
- if any of the options contain illegal charactersNullPointerException
- if the option list or any of its elements arenull
- See Also:
-
acceptsAll
Tells the parser to recognize the given options, and treat them as synonymous.- Parameters:
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.- Returns:
- an object that can be used to flesh out more detail about the options
- Throws:
OptionException
- if any of the options contain illegal charactersNullPointerException
- if the option list or any of its elements arenull
IllegalArgumentException
- if the option list is empty- See Also:
-
nonOptions
NonOptionArgumentSpec<String> nonOptions()Gives an object that represents an access point for non-option arguments on a command line.- Returns:
- an object that can be used to flesh out more detail about the non-option arguments
-
nonOptions
Gives an object that represents an access point for non-option arguments on a command line.- Parameters:
description
- a string that describes the purpose of the non-option arguments. This is used when generating help information about the parser.- Returns:
- an object that can be used to flesh out more detail about the non-option arguments
- See Also:
-
posixlyCorrect
void posixlyCorrect(boolean setting) Tells the parser whether or not to behave "POSIX-ly correct"-ly.- Parameters:
setting
-true
if the parser should behave "POSIX-ly correct"-ly
-
allowsUnrecognizedOptions
void 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. -
recognizeAlternativeLongOptions
void recognizeAlternativeLongOptions(boolean recognize) Tells the parser either to recognize or ignore-W
-style long options.- Parameters:
recognize
-true
if the parser is to recognize the special style of long options
-