Minimize struct copying

by using pointer func receivers and slices of struct pointers where possible.
This commit is contained in:
Dan Buch
2016-05-22 15:20:52 -04:00
parent b35c8a92d2
commit cd10b49473
15 changed files with 452 additions and 372 deletions

14
help.go
View File

@@ -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