Closed
Description
We have encountered some odd behavior in the auto completion.
It appears that arguments with a dash as the second character are detected as flags by mistake.
The full reproducer with various test cases can be found here:
https://go.dev/play/p/UxqRkMcEX2a
The minimal reproducer is the following:
package main
import "github.com/spf13/cobra"
func main() {
root := &cobra.Command{
Use: "root",
}
root.SetArgs([]string{"__complete", "1-ff00:0:1", ""})
root.Execute()
}
which results in the following output:
[Debug] [Error] Subcommand 'root' does not support flag '1'
:0
Completion ended with directive: ShellCompDirectiveDefault
I tracked down the issue and appears that we enter this branch by mistake:
Lines 577 to 595 in fce8d8a
In particular, it appears that the is isFlagArg
classifies the argument as a flag byistake:
Lines 629 to 632 in fce8d8a