mirror of
https://github.com/mikefarah/yq.git
synced 2024-12-19 20:19:04 +00:00
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>
This commit is contained in:
parent
a5f6a80cf6
commit
4b2b47af48
9
acceptance_tests/completion.sh
Executable file
9
acceptance_tests/completion.sh
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
testCompletionRuns() {
|
||||||
|
result=$(./yq __complete "" 2>&1)
|
||||||
|
assertEquals 0 $?
|
||||||
|
assertContains "$result" "Completion ended with directive:"
|
||||||
|
}
|
||||||
|
|
||||||
|
source ./scripts/shunit2
|
2
yq.go
2
yq.go
@ -12,7 +12,7 @@ func main() {
|
|||||||
args := os.Args[1:]
|
args := os.Args[1:]
|
||||||
|
|
||||||
_, _, err := cmd.Find(args)
|
_, _, err := cmd.Find(args)
|
||||||
if err != nil {
|
if err != nil && args[0] != "__complete" {
|
||||||
// default command when nothing matches...
|
// default command when nothing matches...
|
||||||
newArgs := []string{"eval"}
|
newArgs := []string{"eval"}
|
||||||
cmd.SetArgs(append(newArgs, os.Args[1:]...))
|
cmd.SetArgs(append(newArgs, os.Args[1:]...))
|
||||||
|
Loading…
Reference in New Issue
Block a user