6f3304f442afde6e1cf3e7e8641a405d29d2e73d

Author
Carlo Sala <carlosalag@protonmail.com>
Committer
Carlo Sala <carlosalag@protonmail.com>
Date

Message

feat(argocd): add completion plugin

Co-authored-by: Sumudu Lansakara <sumudu.lansakara@ppro.com>

Closes #9900

Diff

 1diff --git a/plugins/argocd/README.md b/plugins/argocd/README.md
 2new file mode 100644
 3index 0000000000000000000000000000000000000000..0f900ff224e18506a8c9d43571eaea6e66b687d1
 4--- /dev/null
 5+++ b/plugins/argocd/README.md
 6@@ -0,0 +1,20 @@
 7+# Argo CD plugin
 8+
 9+This plugin adds completion for the [Argo CD](https://argoproj.github.io/cd/) CLI.
10+
11+To use it, add `argocd` to the plugins array in your zshrc file:
12+
13+```zsh
14+plugins=(... argocd)
15+```
16+
17+This plugin does not add any aliases.
18+
19+## Cache
20+
21+This plugin caches the completion script and is automatically updated asynchronously when the plugin is
22+loaded, which is usually when you start up a new terminal emulator.
23+
24+The cache is stored at:
25+
26+- `$ZSH_CACHE/completions/_argocd` completions script
27diff --git a/plugins/argocd/gh.plugin.zsh b/plugins/argocd/gh.plugin.zsh
28new file mode 100644
29index 0000000000000000000000000000000000000000..8de7b0238c64cb3f8018ef4d643c55d2365f7799
30--- /dev/null
31+++ b/plugins/argocd/gh.plugin.zsh
32@@ -0,0 +1,14 @@
33+# Autocompletion for argocd.
34+if (( ! $+commands[argocd] )); then
35+  return
36+fi
37+
38+# If the completion file doesn't exist yet, we need to autoload it and
39+# bind it to `argocd`. Otherwise, compinit will have already done that.
40+if [[ ! -f "$ZSH_CACHE_DIR/completions/_argocd" ]]; then
41+  typeset -g -A _comps
42+  autoload -Uz _argocd
43+  _comps[argocd]=_argocd
44+fi
45+
46+argocd completion zsh >| "$ZSH_CACHE_DIR/completions/_argocd" &|