9a0f9d7e8bcefb4d9895ca185a35c42366e19b00
- Author
- Draniu <sirsamvimes@gmail.com>
- Committer
- Marc Cornellà <marc.cornella@live.com>
- Date
Message
Better cake3 completion
Diff
1diff --git a/plugins/cakephp3/cakephp3.plugin.zsh b/plugins/cakephp3/cakephp3.plugin.zsh
2index 28d5af2ea5c1a3bfd418850ab0c0508776f80558..2b0f58998af960c944d2f220428f8953d6ab99ce 100644
3--- a/plugins/cakephp3/cakephp3.plugin.zsh
4+++ b/plugins/cakephp3/cakephp3.plugin.zsh
5@@ -1,11 +1,30 @@
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+ has3rdargument=("all" "controller" "fixture" "model" "template")
22 if [ -f bin/cake ]; then
23- compadd `_cakephp3_get_command_list`
24+ if (( CURRENT == 2 )); then
25+ compadd `_cakephp3_get_command_list`
26+ fi
27+ if (( CURRENT == 3 )); then
28+ compadd `_cakephp3_get_sub_command_list`
29+ fi
30+ if (( CURRENT == 4 )); then
31+ if [[ ${has3rdargument[(i)${words[3]}]} -le ${#has3rdargument} ]] ; then ;
32+ compadd `_cakephp3_get_3rd_argument`
33+ fi
34+ fi
35 fi
36 }
37
38@@ -14,6 +33,5 @@ compdef _cakephp3 cake
39
40 #Alias
41 alias c3='bin/cake'
42-
43 alias c3cache='bin/cake orm_cache clear'
44 alias c3migrate='bin/cake migrations migrate'