-verbose
or -help
. To use MultiCommandLine
, create a MultiCommandLine
object with the array of strings you wish to parse (typically the array passed to the utility's main
method), and then consume options from it, providing default values in case the option is not specified by the user. When you have consumed all the options, you invoke the MultiCommandLine
object's getOperands
method to return the remaining operands on the command line. If ``--
'' is specified it is neither an option nor an operand, just a separator between the two lists. The CommandLine.BadInvocationException
is used to signal errors in the construction of the strings, that is, a user error, such as specifying a option that takes an argument but forgetting to provide that argument. See the documentation for MultiCommandLine.main
for an example.
You must call getOperands
for proper behavior, even if you do not use any operands in your command. getOperands
checks for several user errors, including unknown options. If you do not expect to use operands, you should check the return value of getOperands
and complain if any are specified.
No options can be consumed after getOperands
is invoked. Each option may be used only once. Failure to follow these rule is a programmer error that will result in a CommandLine.ProgrammingException
.
MultiCommandLine
provides you several methods to get input streams from the command line. If these do not suffice for your particular needs, you can get the argument as a String
and do your own processing.
@author Sun Microsystems, Inc.
@see java.util.StringTokenizer
|
|
|
|