2009-08-28 11:14:17 -07:00
|
|
|
_rake_does_task_list_need_generating () {
|
2009-09-07 09:18:40 -07:00
|
|
|
if [ ! -f .rake_tasks~ ]; then return 0;
|
2009-08-28 11:14:17 -07:00
|
|
|
else
|
2009-11-08 16:24:20 -07:00
|
|
|
accurate=$(stat -f%m .rake_tasks~)
|
|
|
|
changed=$(stat -f%m Rakefile)
|
2009-08-28 11:14:17 -07:00
|
|
|
return $(expr $accurate '>=' $changed)
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
_rake () {
|
|
|
|
if [ -f Rakefile ]; then
|
|
|
|
if _rake_does_task_list_need_generating; then
|
2009-09-07 09:18:40 -07:00
|
|
|
echo "\nGenerating .rake_tasks~..." > /dev/stderr
|
|
|
|
rake --silent --tasks | cut -d " " -f 2 > .rake_tasks~
|
2009-08-28 11:14:17 -07:00
|
|
|
fi
|
2009-09-07 09:18:40 -07:00
|
|
|
compadd `cat .rake_tasks~`
|
2009-08-28 11:14:17 -07:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2009-09-22 20:36:28 -07:00
|
|
|
compctl -K _rake rake
|
2009-08-28 11:14:17 -07:00
|
|
|
|
|
|
|
function _cap_does_task_list_need_generating () {
|
2009-09-07 09:18:40 -07:00
|
|
|
if [ ! -f .cap_tasks~ ]; then return 0;
|
2009-08-28 11:14:17 -07:00
|
|
|
else
|
2009-09-07 09:18:40 -07:00
|
|
|
accurate=$(stat -f%m .cap_tasks~)
|
2009-08-28 11:14:17 -07:00
|
|
|
changed=$(stat -f%m config/deploy.rb)
|
|
|
|
return $(expr $accurate '>=' $changed)
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function _cap () {
|
|
|
|
if [ -f config/deploy.rb ]; then
|
|
|
|
if _cap_does_task_list_need_generating; then
|
2009-09-07 09:18:40 -07:00
|
|
|
echo "\nGenerating .cap_tasks~..." > /dev/stderr
|
2009-08-28 11:14:17 -07:00
|
|
|
cap show_tasks -q | cut -d " " -f 1 | sed -e '/^ *$/D' -e '1,2D'
|
2009-09-07 09:18:40 -07:00
|
|
|
> .cap_tasks~
|
2009-08-28 11:14:17 -07:00
|
|
|
fi
|
2009-09-07 09:18:40 -07:00
|
|
|
compadd `cat .cap_tasks~`
|
2009-08-28 11:14:17 -07:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2009-09-22 20:36:28 -07:00
|
|
|
compctl -K _cap cap
|