Usage generated by built-in help flag prepends names of OptionGroup
s to command stack if all arguments are optional
#578
Labels
OptionGroup
s to command stack if all arguments are optional
#578
The usage generated by the built-in help flag has the name of the type of all
@OptionGroup
members prepended to the command stack if all options and arguments are optional (i.e. have a default value) and thus differs from the usage in e.g.ParsableCommand.helpMessage()
.ArgumentParser version:
1.0.0
–1.2.2
&main
Swift version: 1.62.15 Apple Swift version 5.7.2 (swiftlang-5.7.2.135.5 clang-1400.0.29.51)
Checklist
main
branch of this packageSteps to Reproduce
ParsableCommand
with at least one@OptionGroup
member and provide default values to all members such that all arguments are optional.Example:
ParsableCommand
through@main
orParsableCommand.main()
.Expected behavior
The usage string that is printed as part of the help message is the same as the usage printed when running it with no arguments and the same as returned by
Test.helpMessage()
.In this case:
USAGE: test [--num <num>] [<arg>]
Actual behavior
The usage string that is printed as part of the help message contains the name of the type of all
@OptionGroup
members before the actual command name.The first line printed when executing the binary with only "--help" as an argument is:
USAGE: group test [--num <num>] [<arg>]
and thus differs from the other methods of getting the usage which are all as expected.
If we change our
ParsableCommand
struct to have at least one non-optional argument by removing one of the default values, the usage returned by the built-in help flag is fixed.For example, with:
the help flag correctly produces:
USAGE: test [--num <num>] <arg>
again.
The text was updated successfully, but these errors were encountered: