Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
yiic bash completion
# basic bash completion for yiic command
#
# simply add the following to your ~/.bash_profile
#
# . ~/path/to/this/file/yiic_bash_completion.bash
#
# note: the . is relevant and you probably have to adjust the path ;-)
#
_yiic()
{
local cur prev opts migrateopts deployopts
COMP_WORDBREAKS=${COMP_WORDBREAKS//:}
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts=""
if [ $COMP_CWORD -le 2 ] ; then
case "$prev" in
./yiic)
opts="api cron message migrate shell test webapp"
;;
api)
opts="check yii doc"
;;
cron)
opts=""
;;
migrate)
opts="up down to mark new history create"
;;
esac
fi
if [ $COMP_CWORD == 3 ] ; then
case "$prev" in
mark|to)
opts="`./yiic migrate bash migrations | tail -1`"
;;
create)
opts="`./yiic migrate bash modules | tail -1`"
;;
esac
fi
#if [ "${cur:0:9}" == "--module=" ] ; then
# opts="${cur:0:9}bla ${cur:0:9}test ${cur:0:9}ixxx ${cur:0:9}hallo"
#fi
# @todo: add support for module param in yiic migrate and yiic migrate create
# @todo: limit completion for versions in mark and to to module, if given
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
}
complete -F _yiic ./yiic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.