Make velero completion zsh command output can be used by source command.

Signed-off-by: Xun Jiang <jxun@vmware.com>
This commit is contained in:
Xun Jiang
2022-05-17 10:01:46 +08:00
parent 89907bd141
commit 3db40a58a4
2 changed files with 10 additions and 1 deletions
+1
View File
@@ -0,0 +1 @@
Make velero completion zsh command output can be used by `source` command.
+9 -1
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: