Minimize struct copying
by using pointer func receivers and slices of struct pointers where possible.
This commit is contained in:
14
help.go
14
help.go
@@ -74,7 +74,7 @@ OPTIONS:
|
||||
{{end}}{{end}}
|
||||
`
|
||||
|
||||
var helpCommand = Command{
|
||||
var helpCommand = &Command{
|
||||
Name: "help",
|
||||
Aliases: []string{"h"},
|
||||
Usage: "Shows a list of commands or help for one command",
|
||||
@@ -90,7 +90,7 @@ var helpCommand = Command{
|
||||
},
|
||||
}
|
||||
|
||||
var helpSubcommand = Command{
|
||||
var helpSubcommand = &Command{
|
||||
Name: "help",
|
||||
Aliases: []string{"h"},
|
||||
Usage: "Shows a list of commands or help for one command",
|
||||
@@ -158,7 +158,15 @@ func ShowCommandHelp(ctx *Context, command string) error {
|
||||
|
||||
// ShowSubcommandHelp prints help for the given subcommand
|
||||
func ShowSubcommandHelp(c *Context) error {
|
||||
return ShowCommandHelp(c, c.Command.Name)
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if c.Command != nil {
|
||||
return ShowCommandHelp(c, c.Command.Name)
|
||||
}
|
||||
|
||||
return ShowCommandHelp(c, "")
|
||||
}
|
||||
|
||||
// ShowVersion prints the version number of the App
|
||||
|
Reference in New Issue
Block a user