cakephp3.plugin.zsh 911 B

123456789101112131415161718192021222324252627282930313233343536373839
  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 schema_cache clear'
  33. alias c3migrate='bin/cake migrations migrate'