yii2.plugin.zsh 506 B

1234567891011121314151617181920212223242526272829
  1. # Yii2 command completion
  2. _yii2_format_command () {
  3. awk '/^- [a-z]+/ { sub(":", "", $2); print $2 }'
  4. }
  5. _yii2 () {
  6. if [ -f ./yii ]; then
  7. _arguments \
  8. '1: :->command'\
  9. '*: :->params'
  10. case $state in
  11. command)
  12. local -a commands
  13. local -a name
  14. if [[ $words[2] == *\/ ]]; then
  15. name=$words[2]
  16. fi
  17. commands=(${(f)"$(./yii help $name --color=0 | _yii2_format_command)"})
  18. compadd -Q -S '' -a -- commands
  19. esac
  20. fi
  21. }
  22. compdef _yii2 yii