Deprecated
since 6.1.
since 6.1 with no plans for a replacement
CommandLinePropertySource implementation backed by a JOpt OptionSet.
OptionParser against the String[] of arguments
supplied to the main method, and create a JOptCommandLinePropertySource
using the resulting OptionSet object:
public static void main(String[] args) {
OptionParser parser = new OptionParser();
parser.accepts("option1");
parser.accepts("option2").withRequiredArg();
OptionSet options = parser.parse(args);
PropertySource<?> ps = new JOptCommandLinePropertySource(options);
// ...
}
If an option has several representations, the most descriptive is expected
to be set last, and is used as the property name of the associated
EnumerablePropertySource#getPropertyNames().
See CommandLinePropertySource for complete general usage examples.
Requires JOpt Simple version 4.3 or higher. Tested against JOpt up until 5.0.
CommandLinePropertySource, joptsimple.OptionParser , joptsimple.OptionSet
| Access | Constructor and Description |
|---|---|
| public | JOptCommandLinePropertySource(OptionSet options)
Create a new |
| public | JOptCommandLinePropertySource(String name, OptionSet options)
Create a new |
| Modifier and Type | Method and Description |
|---|---|
| protected boolean | containsOption(String name)
Implements abstract org. |
| protected List | getNonOptionArgs()
Implements abstract org. |
| public List | getOptionValues(String name)
Implements abstract org. |
| public String[] | getPropertyNames()
Implements abstract org. null).
|
| JOptCommandLinePropertySource | back to summary |
|---|---|
| public JOptCommandLinePropertySource(OptionSet options) Create a new | |
| JOptCommandLinePropertySource | back to summary |
|---|---|
| public JOptCommandLinePropertySource(String name, OptionSet options) Create a new | |
| containsOption | back to summary |
|---|---|
| protected boolean containsOption(String name) Implements abstract org. Doc from org. Return whether the set of option arguments parsed from the command line contains an option with the given name.
| |
| getNonOptionArgs | back to summary |
|---|---|
| protected List Implements abstract org. Doc from org. Return the collection of non-option arguments parsed from the command line.
Never
| |
| getOptionValues | back to summary |
|---|---|
| public List Implements abstract org. Doc from org. Return the collection of values associated with the command line option having the given name.
| |
| getPropertyNames | back to summary |
|---|---|
| public String[] getPropertyNames() Implements abstract org. Doc from org. Return the names of all properties contained by the
source object (never
| |