-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Completions modify os.Args #2257
Copy link
Copy link
Open
Description
I'm trying to workaround #1877 by inspecting os.Args by hand. In some cases cobra accidentally inserts -- into os.Args.
Minimal example:
package main
import (
"os"
"strings"
"github.com/spf13/cobra"
)
func main() {
cmd := &cobra.Command{
TraverseChildren: true,
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]cobra.Completion, cobra.ShellCompDirective) {
cobra.CompErrorln(strings.Join(os.Args[1:], ", "))
return nil, cobra.ShellCompDirectiveDefault
},
}
if err := cmd.Execute(); err != nil {
panic(err)
}
}Expected behaviour:
$ go run . __complete x
[Debug] [Error] __complete, x
:0
Completion ended with directive: ShellCompDirectiveDefaultActual behaviour:
$ go run . __complete x
[Debug] [Error] __complete, --
:0
Completion ended with directive: ShellCompDirectiveDefaultReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels