07.17
bash
saved
uskstc
Note
start of bash_completion script for cake's console
start of bash_completion script for cake's console
- ###
- # @file CakePHP cake console bash completion script
- # @author tclineks
- # @license mit
- _cake()
- {
- local cur prev opts base
- COMPREPLY=()
- cur="${COMP_WORDS[COMP_CWORD]}"
- prev="${COMP_WORDS[COMP_CWORD-1]}"
- # for toplevel, find shells
- if [[ ${COMP_CWORD} -eq 1 ]]; then
- shells=`$1 | grep "Available Shells:" -A 50 | awk '/\t / {print $1}'`
- COMPREPLY=( $(compgen -W "${shells}" -- ${cur}) )
- return 0
- # list available options for bake, just help for others (for now)
- elif [[ ${COMP_CWORD} -eq 2 ]]; then
- case "${prev}" in
- bake)
- opts=`$1 bake help | awk '/^\tbake/ {print $2}'`
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
- return 0
- ;;
- *)
- COMPREPLY=( $(compgen -W "help" -- ${cur}) )
- return 0
- ;;
- esac
- # when we're level three (or more)
- else
- prevprev="${COMP_WORDS[COMP_CWORD-2]}"
- case "${prevprev}" in
- bake)
- case "${prev}" in
- model | controller | view)
- models=`$1 bake ${prev} <&- | awk '/^[0-9]+\./ {print $2}'`
- COMPREPLY=( $(compgen -W "${models}" -- ${cur}) )
- return 0
- ;;
- *)
- ;;
- esac
- ;;
- *)
- ;;
- esac
- fi
- }
- complete -F _cake cake
Parsed in 0.016 seconds, using GeSHi 1.0.7.14