org.apache.commons.cli
public class CommandLine extends Object
Represents list of arguments parsed against a Options descriptor.
It allows querying of a boolean CommandLine, in addition to retrieving the CommandLine for options requiring arguments.
Additionally, any left-over or unrecognized arguments, are available for further processing.
Field Summary | |
---|---|
List | args the unrecognised options/arguments |
Set | options the processed options |
Constructor Summary | |
---|---|
CommandLine()
Creates a command line. |
Method Summary | |
---|---|
void | addArg(String arg)
Add left-over unrecognized option/argument.
|
void | addOption(Option opt)
Add an option to the command line. |
List | getArgList()
Retrieve any left-over non-recognized options and arguments
|
String[] | getArgs()
Retrieve any left-over non-recognized options and arguments
|
Object | getOptionObject(String opt)
Return the Object type of this Option .
|
Object | getOptionObject(char opt)
Return the Object type of this Option .
|
Option[] | getOptions()
Returns an array of the processed Options.
|
String | getOptionValue(String opt)
Retrieve the argument, if any, of this option.
|
String | getOptionValue(char opt)
Retrieve the argument, if any, of this option.
|
String | getOptionValue(String opt, String defaultValue)
Retrieve the argument, if any, of an option.
|
String | getOptionValue(char opt, String defaultValue)
Retrieve the argument, if any, of an option.
|
String[] | getOptionValues(String opt)
Retrieves the array of values, if any, of an option.
|
String[] | getOptionValues(char opt)
Retrieves the array of values, if any, of an option.
|
boolean | hasOption(String opt)
Query to see if an option has been set.
|
boolean | hasOption(char opt)
Query to see if an option has been set.
|
Iterator | iterator()
Returns an iterator over the Option members of CommandLine.
|
Option | resolveOption(String opt) Retrieves the option object given the long or short option as a String |
Parameters: arg the unrecognised option/argument.
Parameters: opt the processed option
Returns: remaining items passed in but not parsed as a List
.
Returns: remaining items passed in but not parsed as an array
Object
type of this Option
.
Parameters: opt the name of the option
Returns: the type of this Option
Object
type of this Option
.
Parameters: opt the name of the option
Returns: the type of opt
Parameters: opt the name of the option
Returns: Value of the argument if option is set, and has an argument, otherwise null.
Parameters: opt the character name of the option
Returns: Value of the argument if option is set, and has an argument, otherwise null.
Parameters: opt name of the option defaultValue is the default value to be returned if the option is not specified
Returns: Value of the argument if option is set, and has an argument,
otherwise defaultValue
.
Parameters: opt character name of the option defaultValue is the default value to be returned if the option is not specified
Returns: Value of the argument if option is set, and has an argument,
otherwise defaultValue
.
Parameters: opt string name of the option
Returns: Values of the argument if option is set, and has an argument, otherwise null.
Parameters: opt character name of the option
Returns: Values of the argument if option is set, and has an argument, otherwise null.
Parameters: opt Short name of the option
Returns: true if set, false if not
Parameters: opt character name of the option
Returns: true if set, false if not
Returns: an Iterator
over the processed Option
members of this CommandLine
Retrieves the option object given the long or short option as a String
Parameters: opt short or long name of the option
Returns: Canonicalized option