1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,32 @@ |
0 |
+# Set this to 1 if you want to cache the tasks |
|
1 |
+cacheTaskList=1 |
|
2 |
+ |
|
3 |
+# Cache filename |
|
4 |
+cacheFile='.cake-task-cache' |
|
5 |
+ |
|
6 |
+_cake_does_target_list_need_generating () { |
|
7 |
+ |
|
8 |
+ if [ $cacheTaskList -eq 0 ]; then |
|
9 |
+ return 1; |
|
10 |
+ fi |
|
11 |
+ |
|
12 |
+ if [ ! -f $cacheFile ]; then return 0; |
|
13 |
+ else |
|
14 |
+ accurate=$(stat -f%m $cacheFile) |
|
15 |
+ changed=$(stat -f%m Cakefile) |
|
16 |
+ return $(expr $accurate '>=' $changed) |
|
17 |
+ fi |
|
18 |
+} |
|
19 |
+ |
|
20 |
+_cake () { |
|
21 |
+ if [ -f Cakefile ]; then |
|
22 |
+ if _cake_does_target_list_need_generating; then |
|
23 |
+ cake | sed -e "s/cake \([^ ]*\) .*/\1/" | grep -v '^$' > $cacheFile |
|
24 |
+ compadd `cat $cacheFile` |
|
25 |
+ else |
|
26 |
+ compadd `cake | sed -e "s/cake \([^ ]*\) .*/\1/" | grep -v '^$'` |
|
27 |
+ fi |
|
28 |
+ fi |
|
29 |
+} |
|
30 |
+ |
|
31 |
+compdef _cake cake |