Browse code

[plugins/grails] Added grails plugin

Zach Riggle authored on 10/09/2011 at 10:48:40
Showing 1 changed files
1 1
new file mode 100755
... ...
@@ -0,0 +1,62 @@
0
+
1
+if [[ ! -d $GRAILS_HOME/scripts ]];
2
+then
3
+    echo "$0:"
4
+    echo "Please set \$GRAILS_HOME to use the 'grails' plugin, and ensure that \$GRAILS_HOME/scripts exists"
5
+fi
6
+
7
+_enumerateGrailsScripts() {
8
+    # Default directoryies
9
+    directories=($GRAILS_HOME/scripts ~/.grails/scripts ./scripts)
10
+
11
+    # Check all of the plugins directories, if they exist
12
+    if [ -d plugins ]
13
+    then
14
+        directories+=(plugins/*/scripts)
15
+    fi
16
+    
17
+    # Enumerate all of the Groovy files
18
+    files=()
19
+    for dir in $directories;
20
+    do
21
+        if [ -d $dir ]
22
+        then
23
+            files+=($dir/*.groovy)
24
+        fi
25
+    done
26
+    
27
+    # Don't try to basename ()
28
+    if [ ${#files} -eq 0 ];
29
+    then
30
+        return
31
+    fi
32
+    
33
+    # - Strip the path
34
+    # - Remove all scripts with a leading '_'
35
+    # - PackagePlugin_.groovy -> PackagePlugin
36
+    # - PackagePlugin         -> Package-Plugin
37
+    # - Package-Plugin        -> package-plugin
38
+    basename $files                             \
39
+        | grep -vE -e '^_'                      \
40
+        | sed -E  -e 's/^_?([^_]+)_?.groovy/\1/'\
41
+                  -e 's/([a-z])([A-Z])/\1-\2/g' \
42
+        | tr "[:upper:]" "[:lower:]"            \
43
+        | sort                                  \
44
+        | uniq
45
+}
46
+ 
47
+_grails() {
48
+    if (( CURRENT == 2 )); then
49
+        scripts=( $(_enumerateGrailsScripts) )
50
+        
51
+        if [ ${#scripts} -ne 0 ];
52
+        then
53
+            _multi_parts / scripts
54
+            return
55
+        fi
56
+    fi
57
+    
58
+    _files
59
+}
60
+ 
61
+compdef _grails grails