Fix duplicate options showing up in command help output #68
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When using option groups to bring options into subcommands that are also
used in parent commands, the help system duplicates the options in the
generated output.
For instance, in the
SubcommandEndToEndTestexample, the--nameargument is listed twice for both the subcommands
CommandAandCommandB, and expected by the test assertion.It is annoying in a simple case like this but causes a lot of unhelpful
noise in help output when you share more and more options across a
command heirarchy.
To solve this we need to keep track of what
HelpGenerator.Section.Elementvalues have already been processed fromparent commands in the command stack. I acheived this by making
Elementconform toHashableto track in aSet.This assumes that we don't need to support re-using command names up and
down a command heirarchy. It doesn't work at all today (you get an error
when trying to use the exact same option in a parent and child
command). If we choose to support this eventually then we'll need to
augment this solution to keep track of where the
Elementwas generatedin the heirarchy.
This also updates the test to properly assert that the
--nameoptionis only output once for the subcommands in
SubcommandEndToEndTest.Checklist