da1ca8876e6bd83ec5b2ae22f3be8e00703122cf
- Author
- Robby Russell <robby@planetargon.com>
- Committer
- Robby Russell <robby@planetargon.com>
- Date
Message
Merge pull request #3404 from ekaragodin/master
Added Yii2 command completion
Diff
1diff --git a/plugins/yii2/README.md b/plugins/yii2/README.md
2new file mode 100644
3index 0000000000000000000000000000000000000000..345b66eb61faf883985de78d84860267d25d49b9
4--- /dev/null
5+++ b/plugins/yii2/README.md
6@@ -0,0 +1,7 @@
7+# Yii2 autocomplete plugin
8+
9+* Adds autocomplete commands and subcommands for yii.
10+
11+## Requirements
12+
13+Autocomplete works from directory where your `yii` file contains.
14diff --git a/plugins/yii2/yii2.plugin.zsh b/plugins/yii2/yii2.plugin.zsh
15new file mode 100644
16index 0000000000000000000000000000000000000000..e8993adf4f6ed4884f8977d7c50935d0ef097f3d
17--- /dev/null
18+++ b/plugins/yii2/yii2.plugin.zsh
19@@ -0,0 +1,29 @@
20+# Yii2 command completion
21+
22+_yii2_format_command () {
23+ awk '/^- [a-z]+/ { sub(":", "", $2); print $2 }'
24+}
25+
26+_yii2 () {
27+ if [ -f ./yii ]; then
28+ _arguments \
29+ '1: :->command'\
30+ '*: :->params'
31+
32+ case $state in
33+ command)
34+
35+ local -a commands
36+ local -a name
37+
38+ if [[ $words[2] == *\/ ]]; then
39+ name=$words[2]
40+ fi
41+
42+ commands=(${(f)"$(./yii help $name --color=0 | _yii2_format_command)"})
43+ compadd -Q -S '' -a -- commands
44+ esac
45+ fi
46+}
47+
48+compdef _yii2 yii