Skip to content

Commit

Permalink
fix: show subcommand info in short help if there are any
Browse files Browse the repository at this point in the history
- 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]>
  • Loading branch information
olizilla committed Oct 22, 2020
1 parent b0de627 commit 8025471
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 3 additions & 1 deletion cli/helptext.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,11 @@ const shortHelpFormat = `USAGE
{{end}}{{if .Subcommands}}
SUBCOMMANDS
{{.Subcommands}}
{{end}}{{if .MoreHelp}}
{{.Indent}}For more information about each command, use:
{{.Indent}}'{{.Path}} <subcmd> --help'
{{end}}{{if .MoreHelp}}
{{.Indent}}for more information about this command, use:
{{.Indent}}'{{.Path}} --help'
{{end}}
`

Expand Down
3 changes: 0 additions & 3 deletions cli/helptext_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ func TestSynopsisGenerator(t *testing.T) {
if !strings.Contains(syn, "[--]") {
t.Fatal("Synopsis should contain options finalizer")
}
if strings.Contains(syn, "For more information about each command") {
t.Fatal("Synopsis should not contain subcommands")
}
}

func TestShortHelp(t *testing.T) {
Expand Down

0 comments on commit 8025471

Please sign in to comment.