public class OptionParser
extends java.lang.Object
Example: the strings "-from", "100", "-to", "200", "duplicate", would be considered to have two options (-from=100 and -to=200) and one argument, "duplicate".
Trigger scripts are given the exact list of arguments to them. Scripts that want to be flexible in what they do can use this class to help parse more complicated arguments lists, e.g.:
var options = Packages.com.telelogic.cs.api.OptionParser.parse(args); var foo = options.getOption("-foo"); // handle option foo
Modifier and Type | Method and Description |
---|---|
java.lang.String[] |
getArgs()
Gets all the arguments, i.e., all the strings that weren't options
or option values.
|
java.lang.String |
getOption(java.lang.String optionName)
Gets a specific option by name.
|
java.util.Map<java.lang.String,java.lang.String> |
getOptions()
Gets all the options, i.e., the strings that started with a "-"
and their values that followed.
|
static OptionParser |
parse(java.lang.String[] args)
Parses a list of strings to find any option/value pairs.
|
public static OptionParser parse(java.lang.String[] args)
args
- an array of strings. Each one starting with a dash ("-") is assumed to
be an option, followed by its value. If an option is repeated, the last
value is used. All leftover strings are considered arguments.OptionParser
that contain the options
and arguments that were parsed.public java.lang.String[] getArgs()
public java.util.Map<java.lang.String,java.lang.String> getOptions()
public java.lang.String getOption(java.lang.String optionName)
optionName
- name of the option to get, including the leading "-".null
if the
option wasn't found.© Copyright IBM Corporation 2000, 2009
US Government Users Restricted Rights--Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
Notices