Merge pull request #186 from nrdufour/master
Fixing the issue with a command with subcommands not showing help message
This commit is contained in:
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 {
|
||||||
|
6
help.go
6
help.go
@ -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…
Reference in New Issue
Block a user