Recent Posts
None | 3 sec ago
Java | 9 sec ago
None | 26 sec ago
None | 1 min ago
C++ | 1 min ago
None | 1 min ago
Objective C | 1 min ago
C++ | 2 min ago
C# | 2 min ago
Bash | 4 min ago
Sitereport
Find cool info about any domain on the internet?
visit sitereport
Free Subdomains
Want a pastebin.com sub-domain for your community?
learn more...
What is pastebin?
Pastebin is a website that hosts all your text & code on dedicated servers for easy sharing.
learn more...
Learn a little bit about the new Pastebin.com on our help page. hide message
By Fernando Takai on the 22nd of Aug 2008 07:33:28 PM Download | Raw | Embed | Report
  1. export GRAILS_VERSION="$(ls -lhr $HOME/.grails | egrep -i '1\.' | head -1 | gawk '{print $9 }')"
  2.  
  3. _get_domain_classes(){
  4.         find ./grails-app/domain -iname *.groovy 2> /dev/null | tr \\n ' ' | sed 's/\.groovy//g' | sed 's/\.\/grails-app\/domain\///g' | tr '/' \.
  5. }
  6.  
  7. _get_tests(){
  8.         find ./test -iname *.groovy 2> /dev/null | sed 's/\.\/test\/integration\///g' | sed 's/\Tests.groovy//g' | tr '/' \.
  9. }
  10.  
  11. _get_plugins(){
  12.         cat $HOME/.grails/$GRAILS_VERSION/plugins/plugins-list.xml 2> /dev/null | grep \<plugin | gawk -F"name=" '{print $2}' | sed 's/\"//g' | sed 's/\/\{0,1\}\>//g'
  13. }
  14.  
  15. _get_scripts(){
  16.         for D in $SCRIPT_DIRS; do
  17.                 if [ -d $D ]
  18.                         then ls -1 $D/*.groovy 2> /dev/null | sed -E 's/(.*)\/(.*)\.groovy/\2/' | sed -E 's/([A-Z])/-\1/g' | sed -E 's/^-//' | tr "[:upper:]" "[:lower:]"
  19.                 fi
  20.         done | sort | uniq | grep -vE "^_"
  21. }
  22.  
  23. _grails_comp(){
  24.         local cur prev opts base
  25.         COMPREPLY=()
  26.         cur="${COMP_WORDS[COMP_CWORD]}"
  27.         prev="${COMP_WORDS[COMP_CWORD-1]}"
  28.         if [ -r ./grails-app ]; then
  29.                 SCRIPT_DIRS="$GRAILS_HOME/scripts ./scripts ~/.grails/scripts"
  30.                 if [ -d plugins ]
  31.                         then for PLUGIN_DIR in $(ls -d plugins/*/scripts 2> /dev/null); do
  32.                         SCRIPT_DIRS="$SCRIPT_DIRS $PLUGIN_DIR"
  33.                         done
  34.                 fi
  35.  
  36.                 opts=$(_get_scripts)
  37.        
  38.                 case "${prev}" in
  39.                         generate-all)
  40.                                 local classes=$(_get_domain_classes)
  41.                                 COMPREPLY=( $(compgen -W "${classes}" -- ${cur}) )
  42.                                 return 0
  43.                                 ;;
  44.                         generate-views)
  45.                                 local classes=$(_get_domain_classes)
  46.                                 COMPREPLY=( $(compgen -W "${classes}" -- ${cur}) )
  47.                                 return 0
  48.                                 ;;
  49.                         generate-controller)
  50.                                 local classes=$(_get_domain_classes)
  51.                                 COMPREPLY=( $(compgen -W "${classes}" -- ${cur}) )
  52.                                 return 0
  53.                                 ;;
  54.                         test-app)
  55.                                 local test_classes=$(_get_tests)
  56.                                 COMPREPLY=( $(compgen -W "${test_classes}" -- ${cur}) )
  57.                                 return 0
  58.                                 ;;
  59.                         install-plugin)
  60.                                 local plugins=$(_get_plugins)
  61.                                 COMPREPLY=( $(compgen -W "${plugins}" -- ${cur}) )
  62.                                 return 0
  63.                                 ;;
  64.                         package-plugin)
  65.                                 COMPREPLY=( $(compgen -f) )
  66.                                 return 0
  67.                                 ;;
  68.                         plugin-info)
  69.                                 local plugins=$(opts)
  70.                                 COMPREPLY=( $(compgen -W "${plugins}" -- ${cur}) )
  71.                                 return 0
  72.                                 ;;
  73.                         help)
  74.                                 local opts=$(_get_scripts)
  75.                                 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
  76.                                 return 0
  77.                                 ;;
  78.                         *)
  79.                         ;;
  80.                 esac
  81.        
  82.                 if [[ "${opts}" =~ "${prev}" ]]; then
  83.                         COMPREPLY=( $(compgen -f) )
  84.                         return 0
  85.                 fi
  86.        
  87.                 COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
  88.                 return 0
  89.         else
  90.                 opts="create-app create-plugin help list-plugins package-plugin plugin-info set-proxy"
  91.                 case "${prev}" in
  92.                         create-app)
  93.                                 COMPREPLY=( $(compgen -f) )
  94.                                 return 0
  95.                                 ;;
  96.                         create-plugin)
  97.                                 COMPREPLY=( $(compgen -f) )
  98.                                 return 0
  99.                                 ;;
  100.                         package-plugin)
  101.                                 COMPREPLY=( $(compgen -f) )
  102.                                 return 0
  103.                                 ;;
  104.                         plugin-info)
  105.                                 local plugins=$(_get_plugins)
  106.                                 COMPREPLY=( $(compgen -W "${plugins}" -- ${cur}) )
  107.                                 return 0
  108.                                 ;;
  109.                         *)
  110.                                 ;;
  111.                 esac
  112.                 COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
  113.                 return 0
  114.         fi
  115. }
  116.  
  117. complete -F _grails_comp grails
Submit a correction or amendment below. Make A New Post
To highlight particular lines, prefix each line with @h@
Syntax highlighting:
Post expiration:
Post exposure:
Name / Title:
Email: