This commit is contained in:
Viktor Benei 2017-06-07 19:43:37 +00:00 committed by GitHub
commit 98c0e33075
2 changed files with 12 additions and 1 deletions

View file

@ -925,6 +925,11 @@ func TestRootSuggestions(t *testing.T) {
cmd := initializeWithRootCmd()
cmd.AddCommand(cmdTimes)
origCmdRun := cmd.Run
defer func() {
cmd.Run = origCmdRun
}()
cmd.Run = nil
tests := map[string]string{
"time": "times",
@ -986,6 +991,12 @@ func TestFlagsBeforeCommand(t *testing.T) {
func TestRemoveCommand(t *testing.T) {
versionUsed = 0
c := initializeWithRootCmd()
origCmdRun := c.Run
defer func() {
c.Run = origCmdRun
}()
c.Run = nil
c.AddCommand(cmdVersion1)
c.RemoveCommand(cmdVersion1)
x := fullTester(c, "version")

View file

@ -521,7 +521,7 @@ func (c *Command) Find(args []string) (*Command, []string, error) {
}
// root command with subcommands, do subcommand checking
if commandFound == c && len(argsWOflags) > 0 {
if commandFound == c && !c.Runnable() && len(argsWOflags) > 0 {
suggestionsString := ""
if !c.DisableSuggestions {
if c.SuggestionsMinimumDistance <= 0 {