cake.plugin.zsh 712 B

12345678910111213141516171819202122232425262728293031323334
  1. # Set this to 1 if you want to cache the tasks
  2. _cake_cache_task_list=1
  3. # Cache filename
  4. _cake_task_cache_file='.cake_task_cache'
  5. _cake_get_target_list () {
  6. cake | grep '^cake ' | sed -e "s/cake \([^ ]*\) .*/\1/" | grep -v '^$'
  7. }
  8. _cake_does_target_list_need_generating () {
  9. if [ ${_cake_cache_task_list} -eq 0 ]; then
  10. return 1;
  11. fi
  12. [ ! -f ${_cake_task_cache_file} ] && return 0;
  13. [ ${_cake_task_cache_file} -nt Cakefile ] && return 0;
  14. return 1;
  15. }
  16. _cake () {
  17. if [ -f Cakefile ]; then
  18. if _cake_does_target_list_need_generating; then
  19. _cake_get_target_list > ${_cake_task_cache_file}
  20. compadd `cat ${_cake_task_cache_file}`
  21. else
  22. compadd `_cake_get_target_list`
  23. fi
  24. fi
  25. }
  26. compdef _cake cake