Fix output of help if it's invalid command

This commit is contained in:
Albert Nigmatzianov 2017-02-27 14:19:59 +05:00
parent f8b7358055
commit 1375fdb780

View file

@ -698,7 +698,6 @@ func (c *Command) Execute() error {
// ExecuteC executes the command. // ExecuteC executes the command.
func (c *Command) ExecuteC() (cmd *Command, err error) { func (c *Command) ExecuteC() (cmd *Command, err error) {
// Regardless of what command execute is called on, run on Root only // Regardless of what command execute is called on, run on Root only
if c.HasParent() { if c.HasParent() {
return c.Root().ExecuteC() return c.Root().ExecuteC()
@ -783,7 +782,7 @@ func (c *Command) initHelpCmd() {
Run: func(c *Command, args []string) { Run: func(c *Command, args []string) {
cmd, _, e := c.Root().Find(args) cmd, _, e := c.Root().Find(args)
if cmd == nil || e != nil { if cmd == nil || e != nil {
c.Printf("Unknown help topic %#q.", args) c.Printf("Unknown help topic %#q\n", args)
c.Root().Usage() c.Root().Usage()
} else { } else {
cmd.Help() cmd.Help()