cake.plugin.zsh 670 Bytes
Newer Older
1
# Set this to 1 if you want to cache the tasks
2
cache_task_list=1
3
4

# Cache filename
5
cache_file='.cake_task_cache'
6
7
8

_cake_does_target_list_need_generating () {

9
	if [ $cache_task_list -eq 0 ]; then
10
11
12
		return 1;
	fi

13
	if [ ! -f $cache_file ]; then return 0;
14
	else
15
		accurate=$(stat -f%m $cache_file)
16
17
18
19
20
21
22
23
		changed=$(stat -f%m Cakefile)
		return $(expr $accurate '>=' $changed)
	fi
}

_cake () {
	if [ -f Cakefile ]; then
		if _cake_does_target_list_need_generating; then
24
25
			cake | sed -e "s/cake \([^ ]*\) .*/\1/" | grep -v '^$' > $cache_file
			compadd `cat $cache_file`
26
27
28
29
30
31
32
		else
			compadd `cake | sed -e "s/cake \([^ ]*\) .*/\1/" | grep -v '^$'`
		fi
	fi
}

compdef _cake cake