You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
933 B
39 lines
933 B
8 years ago
|
#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
|
||
|
|