cakephp3.plugin.zsh 908 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. # CakePHP 3 basic command completion
  2. _cakephp3_get_command_list () {
  3. bin/cake Completion commands
  4. }
  5. _cakephp3_get_sub_command_list () {
  6. bin/cake Completion subcommands ${words[2]}
  7. }
  8. _cakephp3_get_3rd_argument () {
  9. bin/cake ${words[2]} ${words[3]} | \grep '\-\ '| \awk '{print $2}'
  10. }
  11. _cakephp3 () {
  12. local -a has3rdargument
  13. has3rdargument=("all" "controller" "fixture" "model" "template")
  14. if [ -f bin/cake ]; then
  15. if (( CURRENT == 2 )); then
  16. compadd $(_cakephp3_get_command_list)
  17. fi
  18. if (( CURRENT == 3 )); then
  19. compadd $(_cakephp3_get_sub_command_list)
  20. fi
  21. if (( CURRENT == 4 )); then
  22. if [[ ${has3rdargument[(i)${words[3]}]} -le ${#has3rdargument} ]]; then
  23. compadd $(_cakephp3_get_3rd_argument)
  24. fi
  25. fi
  26. fi
  27. }
  28. compdef _cakephp3 bin/cake
  29. compdef _cakephp3 cake
  30. #Alias
  31. alias c3='bin/cake'
  32. alias c3cache='bin/cake orm_cache clear'
  33. alias c3migrate='bin/cake migrations migrate'