Skip to content

Commit

Permalink
chore(cmd): print shortHelp if longHelp is empty
Browse files Browse the repository at this point in the history
Currenlty, `shortHelp` is used when the command is listed from its
parent command, and `longHelp` is used when the command is executed with
its help flag.

What I found a little annoying is if `longHelp` is not provided, which
is the case for the majority of commands, there's no text at all when
the command is invoked with the help flag.

This change ensures the `shortHelp` is printed if `longHelp` is empty.
  • Loading branch information
tbruyelle committed Aug 1, 2023
1 parent 3ade982 commit 5ab5189
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gnovm/cmd/gno/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func newDocCmd(io *commands.IO) *commands.Command {
commands.Metadata{
Name: "doc",
ShortUsage: "doc [flags] <pkgsym>",
ShortHelp: "get documentation for the specified package or symbol (type, function, method, or variable/constant).",
ShortHelp: "get documentation for the specified package or symbol (type, function, method, or variable/constant)",
},
c,
func(_ context.Context, args []string) error {
Expand Down
2 changes: 2 additions & 0 deletions tm2/pkg/commands/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ func usage(c *Command) string {

if c.longHelp != "" {
fmt.Fprintf(&b, "%s\n\n", c.longHelp)
} else {
fmt.Fprintf(&b, "%s.\n\n", c.shortHelp)
}

if len(c.subcommands) > 0 {
Expand Down

0 comments on commit 5ab5189

Please sign in to comment.