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