SilverFire - Dmitry Naumenko
8 years ago
committed by
Carsten Brandt
6 changed files with 230 additions and 44 deletions
@ -0,0 +1,38 @@ |
|||||||
|
#compdef yii |
||||||
|
|
||||||
|
_yii() { |
||||||
|
local state command lastArgument commands options executive |
||||||
|
lastArgument=${words[${#words[@]}]} |
||||||
|
executive=$words[1] |
||||||
|
|
||||||
|
# lookup for command |
||||||
|
for word in ${words[@]:1}; do |
||||||
|
if [[ $word != -* ]]; then |
||||||
|
command=$word |
||||||
|
break |
||||||
|
fi |
||||||
|
done |
||||||
|
|
||||||
|
|
||||||
|
[[ $lastArgument == $command ]] && state="command" |
||||||
|
[[ $lastArgument != $command ]] && state="option" |
||||||
|
|
||||||
|
case $state in |
||||||
|
command) |
||||||
|
commands=("${(@f)$(${executive} help/list 2>/dev/null)}") |
||||||
|
_describe 'command' commands |
||||||
|
;; |
||||||
|
option) |
||||||
|
options=("${(@f)$(${executive} help/usage ${command} 2>/dev/null)}") |
||||||
|
_message -r "$options" |
||||||
|
|
||||||
|
suboptions=("${(@f)$(${executive} help/list-action-options ${command} 2>/dev/null)}") |
||||||
|
_describe -V -o -t suboption 'action options' suboptions |
||||||
|
;; |
||||||
|
*) |
||||||
|
esac |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
compdef _yii yii |
||||||
|
|
Loading…
Reference in new issue