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