2117ee5cf794e1b826751183f4f745718c1491e8

Author
nervo <nervo@nervo.net>
Committer
GitHub <noreply@github.com>
Date

Message

feat(molecule): introduce molecule plugin (#12760)

Diff

 1diff --git a/plugins/molecule/README.md b/plugins/molecule/README.md
 2new file mode 100644
 3index 0000000000000000000000000000000000000000..27b21f9414b486831cf9646a5ea29d413b812c9b
 4--- /dev/null
 5+++ b/plugins/molecule/README.md
 6@@ -0,0 +1,9 @@
 7+# Molecule plugin
 8+
 9+This plugin adds completion for [Molecule](https://ansible.readthedocs.io/projects/molecule/), the project designed to aid in the development and testing of Ansible roles..
10+
11+To use it, add `molecule` to the plugins array in your zshrc file:
12+
13+```zsh
14+plugins=(... molecule)
15+```
16diff --git a/plugins/molecule/molecule.plugin.zsh b/plugins/molecule/molecule.plugin.zsh
17new file mode 100644
18index 0000000000000000000000000000000000000000..65ba85e64103fd8dc88f0107dfce37840de05bcf
19--- /dev/null
20+++ b/plugins/molecule/molecule.plugin.zsh
21@@ -0,0 +1,14 @@
22+# Completion
23+if (( ! $+commands[molecule] )); 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 `molecule`. Otherwise, compinit will have already done that.
29+if [[ ! -f "$ZSH_CACHE_DIR/completions/_molecule" ]]; then
30+  typeset -g -A _comps
31+  autoload -Uz _molecule
32+  _comps[molecule]=_molecule
33+fi
34+
35+_MOLECULE_COMPLETE=zsh_source molecule >| "$ZSH_CACHE_DIR/completions/_molecule" &|