mirror of
https://github.com/spf13/cobra
synced 2024-11-24 22:57:12 +00:00
use root if no other command matches and root is runnable
This commit is contained in:
parent
6a8bd97bdb
commit
45b377d6b1
1 changed files with 2 additions and 2 deletions
|
@ -436,7 +436,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 {
|
||||
|
@ -734,7 +734,7 @@ func (c commandSorterByName) Less(i, j int) bool { return c[i].Name() < c[j].Nam
|
|||
// Commands returns a sorted slice of child commands.
|
||||
func (c *Command) Commands() []*Command {
|
||||
// do not sort commands if it already sorted or sorting was disabled
|
||||
if EnableCommandSorting && !c.commandsAreSorted{
|
||||
if EnableCommandSorting && !c.commandsAreSorted {
|
||||
sort.Sort(commandSorterByName(c.commands))
|
||||
c.commandsAreSorted = true
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue