From 658b0c71fb9c73d0548f5c21e4a5fceb6c4edfd2 Mon Sep 17 00:00:00 2001 From: deads2k Date: Fri, 27 May 2016 08:18:08 -0400 Subject: [PATCH] allow suggestions for non-root commands --- command.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/command.go b/command.go index b92c95cb..ff95e714 100644 --- a/command.go +++ b/command.go @@ -430,13 +430,13 @@ func (c *Command) Find(args []string) (*Command, []string, error) { } // root command with subcommands, do subcommand checking - if commandFound == c && len(argsWOflags) > 0 { + if commandFound != nil && len(argsWOflags) > 0 { suggestionsString := "" - if !c.DisableSuggestions { - if c.SuggestionsMinimumDistance <= 0 { - c.SuggestionsMinimumDistance = 2 + if !commandFound.DisableSuggestions { + if commandFound.SuggestionsMinimumDistance <= 0 { + commandFound.SuggestionsMinimumDistance = 2 } - if suggestions := c.SuggestionsFor(argsWOflags[0]); len(suggestions) > 0 { + if suggestions := commandFound.SuggestionsFor(argsWOflags[0]); len(suggestions) > 0 { suggestionsString += "\n\nDid you mean this?\n" for _, s := range suggestions { suggestionsString += fmt.Sprintf("\t%v\n", s)