07.17 bash saved
uskstc
Tags add more
 
Note
start of bash_completion script for cake's console
  1. ###
  2. # @file CakePHP cake console bash completion script
  3. # @author tclineks
  4. # @license mit
  5.  
  6. _cake()
  7. {
  8.     local cur prev opts base
  9.     COMPREPLY=()
  10.     cur="${COMP_WORDS[COMP_CWORD]}"
  11.     prev="${COMP_WORDS[COMP_CWORD-1]}"
  12.  
  13.     # for toplevel, find shells
  14.     if [[ ${COMP_CWORD} -eq 1 ]]; then
  15.         shells=`$1 | grep "Available Shells:" -A 50 | awk '/\t / {print $1}'`
  16.         COMPREPLY=( $(compgen -W "${shells}" -- ${cur}) )
  17.         return 0
  18.    
  19.     # list available options for bake, just help for others (for now)
  20.     elif [[ ${COMP_CWORD} -eq 2 ]]; then
  21.  
  22.         case "${prev}" in
  23.             bake)
  24.                 opts=`$1 bake help | awk '/^\tbake/ {print $2}'`
  25.                 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
  26.                 return 0
  27.                 ;;
  28.             *)
  29.                 COMPREPLY=( $(compgen -W "help" -- ${cur}) )
  30.                 return 0
  31.             ;;
  32.         esac
  33.  
  34.     # when we're level three (or more)
  35.     else
  36.  
  37.         prevprev="${COMP_WORDS[COMP_CWORD-2]}"
  38.         case "${prevprev}" in
  39.             bake)
  40.             case "${prev}" in
  41.                 model | controller | view)
  42.                     models=`$1 bake ${prev} <&- | awk '/^[0-9]+\./ {print $2}'`
  43.                     COMPREPLY=( $(compgen -W "${models}" -- ${cur}) )
  44.                     return 0
  45.                 ;;
  46.                 *)
  47.                 ;;
  48.             esac
  49.             ;;
  50.             *)
  51.             ;;
  52.         esac
  53.  
  54.     fi
  55.  
  56. }
  57. complete -F _cake cake
  58.  
Parsed in 0.015 seconds, using GeSHi 1.0.7.14

Modify this Paste