in lib/src/parser.dart [265:303]
bool _handleLongOption(String name, String? value) {
var option = _grammar.findByNameOrAlias(name);
if (option != null) {
_args.removeFirst();
if (option.isFlag) {
_validate(
value == null, 'Flag option "$name" should not be given a value.');
_setFlag(_results, option, true);
} else if (value != null) {
// We have a value like --foo=bar.
_setOption(_results, option, value);
} else {
// Option like --foo, so look for the value as the next arg.
_readNextArgAsValue(option);
}
} else if (name.startsWith('no-')) {
// See if it's a negated flag.
var positiveName = name.substring('no-'.length);
option = _grammar.findByNameOrAlias(positiveName);
if (option == null) {
// Walk up to the parent command if possible.
_validate(_parent != null, 'Could not find an option named "$name".');
return _parent!._handleLongOption(name, value);
}
_args.removeFirst();
_validate(option.isFlag, 'Cannot negate non-flag option "$name".');
_validate(option.negatable!, 'Cannot negate option "$name".');
_setFlag(_results, option, false);
} else {
// Walk up to the parent command if possible.
_validate(_parent != null, 'Could not find an option named "$name".');
return _parent!._handleLongOption(name, value);
}
return true;
}