5485d70df2cefa9374c477425d2c1c84646a7d49

Author
Luis Serra <74016165+serrovsky@users.noreply.github.com>
Committer
GitHub <noreply@github.com>
Date

Message

feat(fluxcd): add completion for flux (#11350)

Diff

 1diff --git a/plugins/fluxcd/README.md b/plugins/fluxcd/README.md
 2new file mode 100644
 3index 0000000000000000000000000000000000000000..9723fcc6b7607b6197142548e56251459acb2bf3
 4--- /dev/null
 5+++ b/plugins/fluxcd/README.md
 6@@ -0,0 +1,9 @@
 7+# FluxCD plugin
 8+
 9+This plugin adds completion for [FluxCD](https://fluxcd.io), an open and extensible continuous delivery solution for Kubernetes. Powered by GitOps Toolkit.
10+
11+To use it, add `fluxcd` to the plugins array in your zshrc file:
12+
13+```zsh
14+plugins=(... fluxcd)
15+```
16diff --git a/plugins/fluxcd/fluxcd.plugin.zsh b/plugins/fluxcd/fluxcd.plugin.zsh
17new file mode 100644
18index 0000000000000000000000000000000000000000..d30866a065033eec6a8c69ab009f3311e6fd0373
19--- /dev/null
20+++ b/plugins/fluxcd/fluxcd.plugin.zsh
21@@ -0,0 +1,14 @@
22+# Autocompletion for the FluxCD CLI (flux).
23+if (( ! $+commands[flux] )); then
24+  return
25+fi
26+
27+# If the completion file doesn't exist yet, we need to autoload it and
28+# bind it to `flux`. Otherwise, compinit will have already done that.
29+if [[ ! -f "$ZSH_CACHE_DIR/completions/_flux" ]]; then
30+  typeset -g -A _comps
31+  autoload -Uz _flux
32+  _comps[flux]=_flux
33+fi
34+
35+flux completion zsh >| "$ZSH_CACHE_DIR/completions/_flux" &|