yq/yq.go
whi-tw 4b2b47af48
Fix zsh completion (#1108)
4ec533b introduced a bug which causes the 'hidden' cli parameter
`__complete` to be ignored.

Add a check for this parameter, so that it can pass to `cobra`

Signed-off-by: Tom Whitwell <tom@whi.tw>
2022-02-14 08:03:24 +11:00

26 lines
391 B
Go

package main
import (
"os"
command "github.com/mikefarah/yq/v4/cmd"
)
func main() {
cmd := command.New()
args := os.Args[1:]
_, _, err := cmd.Find(args)
if err != nil && args[0] != "__complete" {
// default command when nothing matches...
newArgs := []string{"eval"}
cmd.SetArgs(append(newArgs, os.Args[1:]...))
}
if err := cmd.Execute(); err != nil {
os.Exit(1)
}
}