-
Notifications
You must be signed in to change notification settings - Fork 375
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
chore(cmd): print shortHelp if longHelp is empty #1011
Conversation
@@ -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)", |
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.
ShortHelp
shouldn't end with a dot. Eventually, a dot is added if ShortHelp
is used when the command is executed with its help flag.
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.
I think it's better to let the point in the definition and have a more basic fprintf in command.go.
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.
Well, this ShortHelp
is the only one that had a final dot, all others haven't.
In addition, if we add dots at the end of ShortHelp
, this will result in this when listing sub-commands :
$ gno
USAGE
<subcommand> [flags] [<arg>...]
Runs the gno development toolkit
SUBCOMMANDS
mod Manage gno.mod.
test Runs the tests for the specified packages.
lint Runs the linter for the specified packages.
run Runs the specified gno files.
build Builds the specified gno package.
precompile Precompiles .gno files to .go.
clean Removes generated files and cached data.
repl Starts a GnoVM REPL.
doc get documentation for the specified package or symbol (type, function, method, or variable/constant).
IMO I prefer without the final dot.
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.
Yep, agree 👍
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.
5ab5189
to
b9cf465
Compare
@@ -252,6 +252,8 @@ func usage(c *Command) string { | |||
|
|||
if c.longHelp != "" { | |||
fmt.Fprintf(&b, "%s\n\n", c.longHelp) | |||
} else if c.shortHelp != "" { | |||
fmt.Fprintf(&b, "%s.\n\n", c.shortHelp) |
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.
fmt.Fprintf(&b, "%s.\n\n", c.shortHelp) | |
fmt.Fprintf(&b, "%s\n\n", c.shortHelp) |
Currenlty,
shortHelp
is used when the command is listed from its parent command, andlongHelp
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 iflongHelp
is empty.Example with `gno test` :
Before the change:
After the change:
Contributors' checklist...
BREAKING CHANGE: xxx
message was included in the description