File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -122,7 +122,8 @@ class Parser {
122122 }
123123
124124 // Check if mandatory and invoke existing callbacks.
125- final ignoreMandatoryOptions = _results.containsKey ('help' );
125+ final ignoreMandatoryOptions =
126+ _results.containsKey ('help' ) || command? .name == 'help' ;
126127 _grammar.options.forEach ((name, option) {
127128 var parsedOption = _results[name];
128129
Original file line number Diff line number Diff line change @@ -799,6 +799,24 @@ Global options:
799799Available commands:
800800 mandatory-option-command A command with a mandatory option
801801
802+ Run "test help <command>" for more information about a command.
803+ ''' ));
804+ });
805+
806+ test ('mandatory global options do not interfere with help command' , () {
807+ runner.argParser.addOption ('mandatory' , mandatory: true );
808+ expect (() => runner.run (['help' ]), prints ('''
809+ A test command runner.
810+
811+ Usage: test <command> [arguments]
812+
813+ Global options:
814+ -h, --help Print this usage information.
815+ --mandatory (mandatory)
816+
817+ Available commands:
818+ help Display help information for test.
819+
802820Run "test help <command>" for more information about a command.
803821''' ));
804822 });
You can’t perform that action at this time.
0 commit comments