-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: hide subcommand from short help when no subcommands #202
base: master
Are you sure you want to change the base?
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 <[email protected]>
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 <[email protected]>
cf7afb2
to
8025471
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -48,3 +49,47 @@ func TestSynopsisGenerator(t *testing.T) { | |||
t.Fatal("Synopsis should contain options finalizer") | |||
} | |||
} | |||
|
|||
func TestShortHelp(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
--help
will 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 [email protected]