Skip to content

Commit

Permalink
command: improve help command docs
Browse files Browse the repository at this point in the history
When generating implicit usage, mention help if there is a help command
defined. Document the hidden -a/--all flag to the help command.
  • Loading branch information
creachadair committed Sep 21, 2024
1 parent 478df19 commit 29f1207
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions help.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ import (
func HelpCommand(topics []HelpTopic) *C {
cmd := &C{
Name: "help",
Usage: "[topic/command]",
Help: `Print help for the specified command or topic.`,
Usage: "[-a|--all] [topic/command]",
Help: `Print help for the specified command or topic.
With -a or --all, also show help for unlisted commands and private flags.`,

CustomFlags: true,

Expand Down
5 changes: 4 additions & 1 deletion utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ func (c *C) usageLines(flags HelpFlags) []string {
tag = joinSpace(tag, "<command>")
}
if tag != "" {
return []string{tag}
lines = append(lines, tag)
}
if hc := c.FindSubcommand("help"); hc != nil && hc.Runnable() {
lines = append(lines, "help")
}
}
return lines
Expand Down

0 comments on commit 29f1207

Please sign in to comment.