Merge pull request #186 from nrdufour/master

Fixing the issue with a command with subcommands not showing help message
main
Jesse Szwedko 10 years ago
commit 3e0905345c

@ -119,7 +119,7 @@ func (c Command) Run(ctx *Context) error {
// Returns true if Command.Name or Command.ShortName matches given name // Returns true if Command.Name or Command.ShortName matches given name
func (c Command) HasName(name string) bool { func (c Command) HasName(name string) bool {
return c.Name == name || c.ShortName == name return c.Name == name || (c.ShortName != "" && c.ShortName == name)
} }
func (c Command) startApp(ctx *Context) error { func (c Command) startApp(ctx *Context) error {

@ -111,6 +111,12 @@ func DefaultAppComplete(c *Context) {
// Prints help for the given command // Prints help for the given command
func ShowCommandHelp(c *Context, command string) { func ShowCommandHelp(c *Context, command string) {
// show the subcommand help for a command with subcommands
if command == "" {
HelpPrinter(SubcommandHelpTemplate, c.App)
return
}
for _, c := range c.App.Commands { for _, c := range c.App.Commands {
if c.HasName(command) { if c.HasName(command) {
HelpPrinter(CommandHelpTemplate, c) HelpPrinter(CommandHelpTemplate, c)

Loading…
Cancel
Save