Blame view
plugins/capistrano/_capistrano
1.06 KB
|
f4c442e7d
|
1 |
#compdef capit |
|
093a6c34b
|
2 |
#autoload |
|
f4c442e7d
|
3 |
# Added `capit` because `cap` is a reserved word. `cap` completion doesn't work. |
|
ed37aae5b
|
4 5 6 7 8 9 10 11 12 13 14 15 |
# http://zsh.sourceforge.net/Doc/Release/Zsh-Modules.html#The-zsh_002fcap-Module
local curcontext="$curcontext" state line ret=1
local -a _configs
_arguments -C \
'1: :->cmds' \
'2:: :->args' && ret=0
_cap_tasks() {
if [[ -f config/deploy.rb || -f Capfile ]]; then
if [[ ! -f .cap_tasks~ ]]; then
|
|
f4c442e7d
|
16 17 |
capit --tasks | sed 's/\(\[\)\(.*\)\(\]\)/\2:/' | awk '{command=$2; $1=$2=$3=""; gsub(/^[ \t\r
]+/, "", $0); gsub(":", "\\:", command); print command"["$0"]"}' > .cap_tasks~
|
|
ed37aae5b
|
18 19 20 21 22 23 24 25 26 |
fi
OLD_IFS=$IFS
IFS=$'
'
_values 'cap commands' $(< .cap_tasks~)
IFS=$OLD_IFS
# zmodload zsh/mapfile
# _values ${(f)mapfile[.cap_tasks~]}
|
|
093a6c34b
|
27 |
fi |
|
ed37aae5b
|
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
}
_cap_stages() {
compadd $(find config/deploy -name \*.rb | cut -d/ -f3 | sed s:.rb::g)
}
case $state in
cmds)
# check if it uses multistage
if [[ -d config/deploy ]]; then
_cap_stages
else
_cap_tasks
fi
ret=0
;;
args)
_cap_tasks
ret=0
;;
esac
return ret
|