Open Fralacticus opened 1 year ago
This was behaviour introduced in version 2.4.2
by #245 that just tripped me up also. Add callback: (_){},
to our addOption and it will work around it.
Add
callback: (_){}
This:
--help
functionality, if any.A manual check seems more reliable. When you make sure no --help
is passed, do this:
for (final option in parser.options.values) {
if (option.mandatory && !results.wasParsed(option.name)) {
throw ArgParserException('Option ${option.name} is mandatory.');
}
}
I think this is actually working as intended. In the OP example the arguments are parsed but not used. From this comment it seems like mandatory
is only enforced when the field is used.
If this is correct, @munificent can we have this added to the documentation for mandatory?
I see that setting the mandatory parameter of the addOption function to true has no effect. In the example below, the arguments array contains none of the 3 mandatories options, and the program throws no exception during parsing.