addMultiOption method
Defines an option that takes multiple values.
The abbr argument is a single-character string that can be used as a
shorthand for this option. For example, abbr: "a" will allow the user to
pass -a value or -avalue.
The help argument is used by usage to describe this option.
The valueHelp argument is used by usage as a name for the value this
argument takes. For example, valueHelp: "FOO" will include
--option=<FOO> rather than just --option in the usage string.
The allowed argument is a list of valid values for this argument. If
it's non-null and the user passes a value that's not included in the
list, parse will throw a FormatException. The allowed values will also
be included in usage.
The allowedHelp argument is a map from values in allowed to
documentation for those values that will be included in usage.
The map may include a subset of the allowed values.
Additional values that are not in allowed should be omitted, however
there is no validation.
When both allowed and allowedHelp are passed, only allowed will
be validated at parse time, and only allowedHelp will be included in
usage output.
The defaultsTo argument indicates the values this option will have if
the user doesn't explicitly pass it in (or [] by default).
The callback argument is invoked with the option's value when the option
is parsed. Note that this makes argument parsing order-dependent in ways
that are often surprising, and its use is discouraged in favor of reading
values from the ArgResults.
If splitCommas is true (the default), multiple options may be passed
by writing --option a,b in addition to --option a --option b.
If hide is true, this option won't be included in usage.
If aliases is provided, these are used as aliases for name. These
aliases will not appear as keys in the options map.
Throws an ArgumentError if:
- There is already an option with name
name. - There is already an option using abbreviation
abbr.
Implementation
void addMultiOption(String name,
{String? abbr,
String? help,
String? valueHelp,
Iterable<String>? allowed,
Map<String, String>? allowedHelp,
Iterable<String>? defaultsTo,
void Function(List<String>)? callback,
bool splitCommas = true,
bool hide = false,
List<String> aliases = const []}) {
_addOption(
name,
abbr,
help,
valueHelp,
allowed,
allowedHelp,
defaultsTo?.toList() ?? <String>[],
callback == null ? null : (List<String> value) => callback(value),
OptionType.multiple,
splitCommas: splitCommas,
hide: hide,
aliases: aliases);
}