66c6260c |
# Set this to 1 if you want to cache the tasks |
8287cc17 |
_cake_cache_task_list=1 |
66c6260c |
# Cache filename |
8287cc17 |
_cake_task_cache_file='.cake_task_cache'
_cake_get_target_list () {
cake | grep '^cake ' | sed -e "s/cake \([^ ]*\) .*/\1/" | grep -v '^$'
} |
66c6260c |
_cake_does_target_list_need_generating () {
|
8287cc17 |
if [ ${_cake_cache_task_list} -eq 0 ]; then |
66c6260c |
return 1;
fi
|
8287cc17 |
if [ ! -f ${_cake_task_cache_file} ]; then return 0; |
66c6260c |
else |
8287cc17 |
accurate=$(stat -f%m $_cake_task_cache_file) |
66c6260c |
changed=$(stat -f%m Cakefile)
return $(expr $accurate '>=' $changed)
fi
}
_cake () {
if [ -f Cakefile ]; then
if _cake_does_target_list_need_generating; then |
8287cc17 |
_cake_get_target_list > ${_cake_task_cache_file}
compadd `cat ${_cake_task_cache_file}` |
66c6260c |
else |
8287cc17 |
compadd `_cake_get_target_list` |
66c6260c |
fi
fi
}
|
8287cc17 |
compdef _cake cake |