Skip to content

Commit

Permalink
Fix zsh completion (#1108)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
whi-tw authored Feb 13, 2022
1 parent a5f6a80 commit 4b2b47a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions acceptance_tests/completion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

testCompletionRuns() {
result=$(./yq __complete "" 2>&1)
assertEquals 0 $?
assertContains "$result" "Completion ended with directive:"
}

source ./scripts/shunit2
2 changes: 1 addition & 1 deletion yq.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func main() {
args := os.Args[1:]

_, _, err := cmd.Find(args)
if err != nil {
if err != nil && args[0] != "__complete" {
// default command when nothing matches...
newArgs := []string{"eval"}
cmd.SetArgs(append(newArgs, os.Args[1:]...))
Expand Down

0 comments on commit 4b2b47a

Please sign in to comment.