1. Jakub Zalewski
  2. oh-my-zsh-mirror

Commits

Robby Russell  committed cceb387 Merge

Merge pull request #595 from zachriggle/grails-plugin

Grails plugin

  • Participants
  • Parent commits 0fe2462, f9c143b
  • Branches master

Comments (0)

Files changed (1)

File plugins/grails/grails.plugin.zsh

View file
  • Ignore whitespace
+_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                             \
+        | 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