2011-07-16 17:15:15 +02:00
|
|
|
# Set this to 1 if you want to cache the tasks
|
2011-07-18 17:05:05 +02:00
|
|
|
cache_task_list=1
|
2011-07-16 17:15:15 +02:00
|
|
|
|
|
|
|
# Cache filename
|
2011-07-18 17:05:05 +02:00
|
|
|
cache_file='.cake_task_cache'
|
2011-07-16 17:15:15 +02:00
|
|
|
|
|
|
|
_cake_does_target_list_need_generating () {
|
|
|
|
|
2011-07-18 17:05:05 +02:00
|
|
|
if [ $cache_task_list -eq 0 ]; then
|
2011-07-16 17:15:15 +02:00
|
|
|
return 1;
|
|
|
|
fi
|
|
|
|
|
2011-07-18 17:05:05 +02:00
|
|
|
if [ ! -f $cache_file ]; then return 0;
|
2011-07-16 17:15:15 +02:00
|
|
|
else
|
2011-07-18 17:05:05 +02:00
|
|
|
accurate=$(stat -f%m $cache_file)
|
2011-07-16 17:15:15 +02:00
|
|
|
changed=$(stat -f%m Cakefile)
|
|
|
|
return $(expr $accurate '>=' $changed)
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
_cake () {
|
|
|
|
if [ -f Cakefile ]; then
|
|
|
|
if _cake_does_target_list_need_generating; then
|
2011-07-18 17:05:05 +02:00
|
|
|
cake | sed -e "s/cake \([^ ]*\) .*/\1/" | grep -v '^$' > $cache_file
|
|
|
|
compadd `cat $cache_file`
|
2011-07-16 17:15:15 +02:00
|
|
|
else
|
|
|
|
compadd `cake | sed -e "s/cake \([^ ]*\) .*/\1/" | grep -v '^$'`
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
compdef _cake cake
|