mirror of
https://github.com/spf13/cobra
synced 2025-05-05 21:07:24 +00:00
Merge 5513220bc3
into 99ff9334bd
This commit is contained in:
commit
98c0e33075
2 changed files with 12 additions and 1 deletions
|
@ -925,6 +925,11 @@ func TestRootSuggestions(t *testing.T) {
|
||||||
|
|
||||||
cmd := initializeWithRootCmd()
|
cmd := initializeWithRootCmd()
|
||||||
cmd.AddCommand(cmdTimes)
|
cmd.AddCommand(cmdTimes)
|
||||||
|
origCmdRun := cmd.Run
|
||||||
|
defer func() {
|
||||||
|
cmd.Run = origCmdRun
|
||||||
|
}()
|
||||||
|
cmd.Run = nil
|
||||||
|
|
||||||
tests := map[string]string{
|
tests := map[string]string{
|
||||||
"time": "times",
|
"time": "times",
|
||||||
|
@ -986,6 +991,12 @@ func TestFlagsBeforeCommand(t *testing.T) {
|
||||||
func TestRemoveCommand(t *testing.T) {
|
func TestRemoveCommand(t *testing.T) {
|
||||||
versionUsed = 0
|
versionUsed = 0
|
||||||
c := initializeWithRootCmd()
|
c := initializeWithRootCmd()
|
||||||
|
origCmdRun := c.Run
|
||||||
|
defer func() {
|
||||||
|
c.Run = origCmdRun
|
||||||
|
}()
|
||||||
|
c.Run = nil
|
||||||
|
|
||||||
c.AddCommand(cmdVersion1)
|
c.AddCommand(cmdVersion1)
|
||||||
c.RemoveCommand(cmdVersion1)
|
c.RemoveCommand(cmdVersion1)
|
||||||
x := fullTester(c, "version")
|
x := fullTester(c, "version")
|
||||||
|
|
|
@ -521,7 +521,7 @@ func (c *Command) Find(args []string) (*Command, []string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// root command with subcommands, do subcommand checking
|
// root command with subcommands, do subcommand checking
|
||||||
if commandFound == c && len(argsWOflags) > 0 {
|
if commandFound == c && !c.Runnable() && len(argsWOflags) > 0 {
|
||||||
suggestionsString := ""
|
suggestionsString := ""
|
||||||
if !c.DisableSuggestions {
|
if !c.DisableSuggestions {
|
||||||
if c.SuggestionsMinimumDistance <= 0 {
|
if c.SuggestionsMinimumDistance <= 0 {
|
||||||
|
|
Loading…
Add table
Reference in a new issue