diff options
author | Zach Riggle <zach@riggle.me> | 2011-09-10 06:48:40 -0400 |
---|---|---|
committer | Zach Riggle <zach@riggle.me> | 2011-09-10 07:07:23 -0400 |
commit | c6e8c856cb59e24362fe50fd93de097f30205420 (patch) | |
tree | 63b8776314e84693809b6dcb7e33863f3b4bdc4c /plugins/grails | |
parent | 762b55bb2bc0452ce3f5f2f21bc22b61936ef704 (diff) | |
download | zsh-c6e8c856cb59e24362fe50fd93de097f30205420.tar.gz zsh-c6e8c856cb59e24362fe50fd93de097f30205420.tar.bz2 zsh-c6e8c856cb59e24362fe50fd93de097f30205420.zip |
[plugins/grails] Added grails plugin
Diffstat (limited to 'plugins/grails')
-rwxr-xr-x | plugins/grails/grails.plugin.zsh | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/plugins/grails/grails.plugin.zsh b/plugins/grails/grails.plugin.zsh new file mode 100755 index 000000000..95b1324e7 --- /dev/null +++ b/plugins/grails/grails.plugin.zsh @@ -0,0 +1,62 @@ + +if [[ ! -d $GRAILS_HOME/scripts ]]; +then + echo "$0:" + echo "Please set \$GRAILS_HOME to use the 'grails' plugin, and ensure that \$GRAILS_HOME/scripts exists" +fi + +_enumerateGrailsScripts() { + # Default directoryies + directories=($GRAILS_HOME/scripts ~/.grails/scripts ./scripts) + + # Check all of the plugins directories, if they exist + if [ -d plugins ] + then + directories+=(plugins/*/scripts) + fi + + # Enumerate all of the Groovy files + files=() + for dir in $directories; + do + if [ -d $dir ] + then + files+=($dir/*.groovy) + fi + done + + # Don't try to basename () + if [ ${#files} -eq 0 ]; + then + return + fi + + # - Strip the path + # - Remove all scripts with a leading '_' + # - PackagePlugin_.groovy -> PackagePlugin + # - PackagePlugin -> Package-Plugin + # - Package-Plugin -> package-plugin + basename $files \ + | grep -vE -e '^_' \ + | sed -E -e 's/^_?([^_]+)_?.groovy/\1/'\ + -e 's/([a-z])([A-Z])/\1-\2/g' \ + | tr "[:upper:]" "[:lower:]" \ + | sort \ + | uniq +} + +_grails() { + if (( CURRENT == 2 )); then + scripts=( $(_enumerateGrailsScripts) ) + + if [ ${#scripts} -ne 0 ]; + then + _multi_parts / scripts + return + fi + fi + + _files +} + +compdef _grails grails |