66c6260c10422bf50c474c9654a7928ce99e7ceb

Author
Paul Serby <paul.serby@clock.co.uk>
Committer
Paul Serby <paul.serby@clock.co.uk>
Date

Message

Completion for cake the coffee-script build tool

Diff

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