org.apache.commons.cli
public class Options extends Object
Main entry-point into the library.
Options represents a collection of Option objects, which describe the possible options for a command-line.
It may flexibly parse long and short options, with or without values. Additionally, it may parse only a portion of a commandline, allowing for flexible multi-stage parsing.
Version: $Revision: 542144 $
Field Summary | |
---|---|
Map | longOpts a map of the options with the long key |
Map | optionGroups a map of the option groups |
List | requiredOpts a map of the required options |
Map | shortOpts a map of the options with the character key |
Constructor Summary | |
---|---|
Options() Construct a new Options descriptor |
Method Summary | |
---|---|
Options | addOption(String opt, boolean hasArg, String description)
Add an option that only contains a short-name.
|
Options | addOption(String opt, String longOpt, boolean hasArg, String description)
Add an option that contains a short-name and a long-name.
|
Options | addOption(Option opt)
Adds an option instance
|
Options | addOptionGroup(OptionGroup group)
Add the specified option group.
|
Option | getOption(String opt)
Retrieve the named Option
|
OptionGroup | getOptionGroup(Option opt)
Returns the OptionGroup the opt
belongs to. |
Collection | getOptionGroups()
Lists the OptionGroups that are members of this Options instance. |
Collection | getOptions()
Retrieve a read-only list of options in this set
|
List | getRequiredOptions()
Returns the required options as a
java.util.Collection .
|
boolean | hasOption(String opt) |
List | helpOptions()
Returns the Options for use by the HelpFormatter.
|
String | toString()
Dump state, suitable for debugging.
|
Parameters: opt Short single-character name of the option. hasArg flag signally if an argument is required after this option description Self-documenting description
Returns: the resulting Options instance
Parameters: opt Short single-character name of the option. longOpt Long multi-character name of the option. hasArg flag signally if an argument is required after this option description Self-documenting description
Returns: the resulting Options instance
Parameters: opt the option that is to be added
Returns: the resulting Options instance
Parameters: group the OptionGroup that is to be added
Returns: the resulting Options instance
Parameters: opt short or long name of the Option
Returns: the option represented by opt
opt
belongs to.Parameters: opt the option whose OptionGroup is being queried.
Returns: the OptionGroup if opt
is part
of an OptionGroup, otherwise return null
Returns: a Collection of OptionGroup instances.
Returns: read-only Collection of Option objects in this descriptor
java.util.Collection
.
Returns: Collection of required options
Parameters: opt short or long name of the Option
Returns: true if the named Option is a member of this Options
Returns: the List of Options
Returns: Stringified form of this object