2011-07-16 15:15:15 +00:00
|
|
|
# Set this to 1 if you want to cache the tasks
|
2011-09-24 16:09:57 +00:00
|
|
|
_cake_cache_task_list=1
|
2011-07-16 15:15:15 +00:00
|
|
|
|
|
|
|
# Cache filename
|
2011-09-24 16:09:57 +00:00
|
|
|
_cake_task_cache_file='.cake_task_cache'
|
|
|
|
|
|
|
|
_cake_get_target_list () {
|
|
|
|
cake | grep '^cake ' | sed -e "s/cake \([^ ]*\) .*/\1/" | grep -v '^$'
|
|
|
|
}
|
2011-07-16 15:15:15 +00:00
|
|
|
|
|
|
|
_cake_does_target_list_need_generating () {
|
|
|
|
|
2011-09-24 16:09:57 +00:00
|
|
|
if [ ${_cake_cache_task_list} -eq 0 ]; then
|
2011-07-16 15:15:15 +00:00
|
|
|
return 1;
|
|
|
|
fi
|
|
|
|
|
2013-03-12 17:11:18 +00:00
|
|
|
[ ! -f ${_cake_task_cache_file} ] && return 0;
|
2014-12-17 10:11:53 +00:00
|
|
|
[ Cakefile -nt ${_cake_task_cache_file} ] && return 0;
|
2013-03-12 17:11:18 +00:00
|
|
|
return 1;
|
2011-07-16 15:15:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_cake () {
|
|
|
|
if [ -f Cakefile ]; then
|
|
|
|
if _cake_does_target_list_need_generating; then
|
2011-09-24 16:09:57 +00:00
|
|
|
_cake_get_target_list > ${_cake_task_cache_file}
|
|
|
|
compadd `cat ${_cake_task_cache_file}`
|
2011-07-16 15:15:15 +00:00
|
|
|
else
|
2011-09-24 16:09:57 +00:00
|
|
|
compadd `_cake_get_target_list`
|
2011-07-16 15:15:15 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2013-03-12 17:11:18 +00:00
|
|
|
compdef _cake cake
|