Return the value for the option.
Return the value for the option. This will be either the default specified,
if the user did not invoke the option, or the _last_ invocation of the
command line option. In other words, if the argument list contains
--foo bar1 --foo bar2
, then Some("bar2")
is returned.
Note: Use remaining
to get the tokens not associated with a flag.
getAll
Return a Seq
with all values specified for the option.
Return a Seq
with all values specified for the option. This supports
the case where an option can be repeated on the command line.
If the user did not specify the option, then default is mapped to a
return value as follows:
None
=> Nil
Some(x)
=> Seq(x)
If the user specified one or more invocations, then all of the values
are returned in Seq
. For example, for --foo bar1 --foo bar2
, then
this method returns Seq("bar1", "bar2")
.
Note: Use remaining
to get the tokens not associated with a flag.
get
Like getAll
, but an alternative is specified, if no value for exists.
Like getAll
, but an alternative is specified, if no value for exists.
Note: Use remaining
to get the tokens not associated with a flag.
Like get
, but an alternative is specified, if no value for the option
exists, so the return value is of type V
, rather than Option[V]
.
Like get
, but an alternative is specified, if no value for the option
exists, so the return value is of type V
, rather than Option[V]
.
Note: Use remaining
to get the tokens not associated with a flag.
Were errors found in the argument list? If so, print the error messages, followed by the help message and return true.
Were errors found in the argument list? If so, print the error messages, followed by the help message and return true. Otherwise, return false. Callers may wish to exit if true is returned.
Was the help option invoked?
If so, print the help message to the output PrintStream
and return true.
Was the help option invoked?
If so, print the help message to the output PrintStream
and return true.
Otherwise, return false. Callers may wish to exit if true is returned.
Parse the user-specified arguments, using parserChain
.
Parse the user-specified arguments, using parserChain
. Note that if
an unrecognized flag is found, i.e., a string that starts with one or two
'-', it is an error. Otherwise, all unrecognized options are added to the
resulting values
in a Seq[String]
with the key, "remaining".
Args
Print all the current values.
Print all the current values. Before any parsing is done, the values are the defaults. After parsing, they are the defaults overridden by all the user-supplied options. If an option is specified multiple times, then all values are shown.
printValues
Print the current values.
Print the current values. Before any parsing is done, the values are
the defaults. After parsing, they are the defaults overridden by any
user-supplied options. If an option is specified multiple times, then
the _last_ invocation is shown.
Note that the "remaining" arguments are the same in this output and in
printAllValues
.
printAllValues
Convenience method to parse the argument list and handle errors or help requests.
Convenience method to parse the argument list and handle errors or
help requests.
If a parsing error occurs or help is requested, an appropriate message
is printed to the out
argument and the program exits with a call to
sys.exit(n)
with the integer exit returned by the sister Args#process
method. Normally, the default values for the out
and exit
arguments
are only overridden for testing.
For more customized handling, {@see #parse}.
Args
Ignore all parse errors if help was requested
Ignore all parse errors if help was requested
Unknown option that starts with one or two '-' matches!
Unknown option that starts with one or two '-' matches!
Contains the options defined, the current values, which are the defaults before parsing and afterwards are the defaults overridden by the actual invocation options, and contains any parsing errors that were found, which is empty before parse is called. In order to properly construct the default values, this constructor is protected. Instead, use the companion Args.apply to construct initial instances correctly. Subsequent calls to
Args.parse
return new, updated instances.