222d84300febdc7d59696ac4876cf06e0d535436
- Author
- Marc Cornellà <marc.cornella@live.com>
- Committer
- Marc Cornellà <marc.cornella@live.com>
- Date
Message
Merge branch 'Draniu/patch-1'
Close #5101
Diff
1diff --git a/plugins/cakephp3/cakephp3.plugin.zsh b/plugins/cakephp3/cakephp3.plugin.zsh
2index 28d5af2ea5c1a3bfd418850ab0c0508776f80558..dbfbeba3b267f3a1c8aa85b61ab33afade2898d5 100644
3--- a/plugins/cakephp3/cakephp3.plugin.zsh
4+++ b/plugins/cakephp3/cakephp3.plugin.zsh
5@@ -1,11 +1,31 @@
6 # CakePHP 3 basic command completion
7 _cakephp3_get_command_list () {
8- cakephp3commands=($(bin/cake completion commands));printf "%s\n" "${cakephp3commands[@]}"
9+ bin/cake Completion commands
10+}
11+
12+_cakephp3_get_sub_command_list () {
13+ bin/cake Completion subcommands ${words[2]}
14+}
15+
16+_cakephp3_get_3rd_argument () {
17+ bin/cake ${words[2]} ${words[3]} | \grep '\-\ '| \awk '{print $2}'
18 }
19
20 _cakephp3 () {
21- if [ -f bin/cake ]; then
22- compadd `_cakephp3_get_command_list`
23+ local -a has3rdargument
24+ has3rdargument=("all" "controller" "fixture" "model" "template")
25+ if [ -f bin/cake ]; then
26+ if (( CURRENT == 2 )); then
27+ compadd $(_cakephp3_get_command_list)
28+ fi
29+ if (( CURRENT == 3 )); then
30+ compadd $(_cakephp3_get_sub_command_list)
31+ fi
32+ if (( CURRENT == 4 )); then
33+ if [[ ${has3rdargument[(i)${words[3]}]} -le ${#has3rdargument} ]]; then
34+ compadd $(_cakephp3_get_3rd_argument)
35+ fi
36+ fi
37 fi
38 }
39
40@@ -14,6 +34,5 @@ compdef _cakephp3 cake
41
42 #Alias
43 alias c3='bin/cake'
44-
45 alias c3cache='bin/cake orm_cache clear'
46 alias c3migrate='bin/cake migrations migrate'