Merge pull request #4914 from blackpiglet/4912-fix-completion-zsh

Make velero completion zsh command output can be used by `source` com…
pull/4934/head
Scott Seago 2022-05-23 10:05:12 -04:00 committed by GitHub
commit 471e357952
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -0,0 +1 @@
Make velero completion zsh command output can be used by `source` command.

View File

@ -66,7 +66,15 @@ $ velero completion fish > ~/.config/fish/completions/velero.fish
case "bash":
cmd.Root().GenBashCompletion(os.Stdout)
case "zsh":
cmd.Root().GenZshCompletion(os.Stdout)
// # fix #4912
// cobra does not support zsh completion ouptput used by source command
// according to https://github.com/spf13/cobra/issues/1529
// Need to append compdef manually to do that.
zshHead := "#compdef velero\ncompdef _velero velero\n"
out := os.Stdout
out.Write([]byte(zshHead))
cmd.Root().GenZshCompletion(out)
case "fish":
cmd.Root().GenFishCompletion(os.Stdout, true)
default: