fix: hide subcommand from short help when no subcommands#202
Conversation
ShortHelp always shows the subcommand help prompt even if there are no subcommands. Add a test to demo it. License: MIT Signed-off-by: Oli Evans <oli@tableflip.io>
|
Thank you for submitting this PR!
Getting other community members to do a review would be great help too on complex PRs (you can ask in the chats/forums). If you are unsure about something, just leave us a comment.
We currently aim to provide initial feedback/triaging within two business days. Please keep an eye on any labelling actions, as these will indicate priorities and status of your contribution. |
- only invite the user to check help for subcommands if there are any - invite the user to check out the LongHelp for this command with --help License: MIT Signed-off-by: Oli Evans <oli@tableflip.io>
cf7afb2 to
8025471
Compare
aschmahmann
left a comment
There was a problem hiding this comment.
Left a few tiny suggestions/comments but LGTM. Thanks 😄.
Note: Does this effect our documentation generation at all or does it not utilize this codepath?
| {{.Indent}}For more information about each command, use: | ||
| {{.Indent}}'{{.Path}} <subcmd> --help' |
There was a problem hiding this comment.
Is it at all confusing that we let people know explicitly that they can run --help, but not the short -h?
I suspect not but figured I'd check in.
| } | ||
| } | ||
|
|
||
| func TestShortHelp(t *testing.T) { |
There was a problem hiding this comment.
Could you also add a test that checks on subcommands? The two things I'd like to watch for are:
- I'd like some signal that these tests are still useful even if someone changes "For more information about each command" to be rephrased slightly. This could also be aided by checking a constant.
- Making sure that subcommands are printed
| {{.Indent}}For more information about each command, use: | ||
| {{.Indent}}'{{.Path}} <subcmd> --help' | ||
| {{end}}{{if .MoreHelp}} | ||
| {{.Indent}}for more information about this command, use: |
There was a problem hiding this comment.
lowercase f here intentional?
ShortHelp always shows the subcommand help prompt even if there are no subcommands.
The last 2 lines of the short help are supposed to let the user know that
--helpwill get them more help about this command. There should be no invitation to check subcommands if there are no subcommands for this command.This PR changes things so we:
License: MIT
Signed-off-by: Oli Evans oli@tableflip.io