grails.plugin.zsh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. _enumerateGrailsScripts() {
  2. # Default directoryies
  3. directories=($GRAILS_HOME/scripts ~/.grails/scripts ./scripts)
  4. # Check all of the plugins directories, if they exist
  5. if [ -d plugins ]
  6. then
  7. directories+=(plugins/*/scripts)
  8. fi
  9. # Enumerate all of the Groovy files
  10. files=()
  11. for dir in $directories;
  12. do
  13. if [ -d $dir ]
  14. then
  15. files+=($dir/[^_]*.groovy)
  16. fi
  17. done
  18. # Don't try to basename ()
  19. if [ ${#files} -eq 0 ];
  20. then
  21. return
  22. fi
  23. # - Strip the path
  24. # - Remove all scripts with a leading '_'
  25. # - PackagePlugin_.groovy -> PackagePlugin
  26. # - PackagePlugin -> Package-Plugin
  27. # - Package-Plugin -> package-plugin
  28. basename $files \
  29. | sed -E -e 's/^_?([^_]+)_?.groovy/\1/'\
  30. -e 's/([a-z])([A-Z])/\1-\2/g' \
  31. | tr "[:upper:]" "[:lower:]" \
  32. | sort \
  33. | uniq
  34. }
  35. _grails() {
  36. if (( CURRENT == 2 )); then
  37. scripts=( $(_enumerateGrailsScripts) )
  38. if [ ${#scripts} -ne 0 ];
  39. then
  40. _multi_parts / scripts
  41. return
  42. fi
  43. fi
  44. _files
  45. }
  46. compdef _grails grails