updated on Sun Jan 22 20:01:29 UTC 2012
[aur-mirror.git] / symfony / symfony.bash
blob5e2ec6f89f5f1dce13735b25aecfb1f033917863
1 _symfony()
2 {
3 local cur prev action
4 COMPREPLY=()
5 cur=${COMP_WORDS[COMP_CWORD]}
6 prev=${COMP_WORDS[COMP_CWORD-1]}
7 action=${COMP_WORDS[1]}
9 case "$prev" in
10 "init-module"|"propel-generate-crud"|"propel-init-crud"|"propel-init-admin"|"generate:module"|"propel:generate-crud"|"propel:init-admin")
11 COMPREPLY=( $( compgen -W "$( ls -1 apps 2>/dev/null | sed -e 's/ /\\ /g' | sed -e 's/\/$//g' )" -- $cur ) )
13 return 0
16 "init-project"|"generate:project")
17 COMPREPLY=( $( compgen -W "$( pwd | perl -pe "s/^.*?([^\/]+)$/\$1/g" )" -- $cur ) )
19 return 0
22 "init-app"|"generate:app")
23 COMPREPLY=( $( compgen -W "frontend backend" -- $cur ) )
25 return 0
26 ;;
28 "sync")
29 if (($COMP_CWORD == 3)); then
30 COMPREPLY=( $( compgen -W 'go' -- $cur))
33 return 0
36 *symfony)
37 SYMFONY_VERSION=$( $prev -V | sed 's/^symfony version //g' | awk -F '.' '{print $1 "." $2;}' )
39 case "$SYMFONY_VERSION" in
40 0.*)
41 # Versions less than 1.0 are not supported.
42 COMPREPLY=()
45 "1.0")
46 COMPREPLY=( $( compgen -W "$( $prev -T | awk '/^ /' | cut -d ' ' -f 3 )" -- $cur ) )
50 COMPREPLY=( $( compgen -W "$(
51 NAMESPACE=''
52 OLD_IFS=$IFS
54 IFS=$'\n'
55 for line in $( $prev -T ); do
56 if [ $line != 'Available tasks:' ]; then
57 if [ ${line:0:2} == ' ' ]; then
58 TASK=$(echo $line | awk -F ':' '{print $2;}' | cut -d ' ' -f 1)
59 if [ -z $NAMESPACE ]; then
60 echo $TASK
61 else
62 echo $NAMESPACE:$TASK
64 else
65 NAMESPACE=$line
68 done
70 IFS=$OLD_IFS
71 )" -- $cur ) )
73 # Work-around bash_completion issue where bash interprets a colon as a separator.
74 # Work-around borrowed from the darcs work-around for the same issue.
75 local colonprefixes=${cur%"${cur##*:}"}
76 local i=${#COMPREPLY[*]}
77 while [ $((--i)) -ge 0 ]; do
78 COMPREPLY[$i]=${COMPREPLY[$i]#"$colonprefixes"}
79 done
81 esac
83 return 0
84 ;;
87 case "$action" in
88 "propel-generate-crud"|"propel-init-crud"|"propel-init-admin"|"propel:generate-crud"|"propel:init-admin")
89 if (($COMP_CWORD == 3)); then
90 COMPREPLY=( $( compgen -W "$( find lib/model -maxdepth 1 -name '*.php' -exec basename '{}' '.php' ';' | grep -v 'Peer$' | tr [:upper:] [:lower:] )" -- $cur ) )
91 elif (($COMP_CWORD == 4)); then
92 COMPREPLY=( $( compgen -W "$( find lib/model -maxdepth 1 -name '*.php' -exec basename '{}' '.php' ';' | grep -v 'Peer$' )" -- $cur ) )
95 return 0
97 esac
99 return 0
101 esac
103 return 0
106 complete -F _symfony symfony