diff options
| author | Andrew Janke <andrew@apjanke.net> | 2015-09-23 18:53:05 -0400 | 
|---|---|---|
| committer | Andrew Janke <andrew@apjanke.net> | 2015-09-23 18:53:05 -0400 | 
| commit | 96ff86142e9037e707f9cde8ab69e0425a0559c6 (patch) | |
| tree | 217cb5e2b4a1c55afec79984c3c3c0a9efe2bf69 /plugins/capistrano/_capistrano | |
| parent | 502f08b5e19716d43a7ec8b006178a7b017f68cd (diff) | |
| parent | 76a26a2a59d8c6d0f65a4426cdb93920e255aea7 (diff) | |
| download | zsh-96ff86142e9037e707f9cde8ab69e0425a0559c6.tar.gz zsh-96ff86142e9037e707f9cde8ab69e0425a0559c6.tar.bz2 zsh-96ff86142e9037e707f9cde8ab69e0425a0559c6.zip | |
Merge branch 'master' into installer-cygwin-support-3
Conflicts:
	tools/install.sh
Diffstat (limited to 'plugins/capistrano/_capistrano')
| -rw-r--r-- | plugins/capistrano/_capistrano | 53 | 
1 files changed, 46 insertions, 7 deletions
| diff --git a/plugins/capistrano/_capistrano b/plugins/capistrano/_capistrano index 3cadf3d54..e6e71ffcc 100644 --- a/plugins/capistrano/_capistrano +++ b/plugins/capistrano/_capistrano @@ -1,10 +1,49 @@ -#compdef cap +#compdef shipit  #autoload -if [[ -f config/deploy.rb || -f Capfile ]]; then -  if [[ ! -f .cap_tasks~ || config/deploy.rb -nt .cap_tasks~ ]]; then -    echo "\nGenerating .cap_tasks~..." > /dev/stderr -    cap -v --tasks | grep '#' | cut -d " " -f 2 > .cap_tasks~ +# Added `shipit` because `cap` is a reserved word. `cap` completion doesn't work. +# 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 +      shipit -v --tasks | sed 's/\(\[\)\(.*\)\(\]\)/\2:/' | awk '{command=$2; $1=$2=$3=""; gsub(/^[ \t\r\n]+/, "", $0); gsub(":", "\\:", command); print command"["$0"]"}' > .cap_tasks~ +    fi + +    OLD_IFS=$IFS +    IFS=$'\n' +    _values 'cap commands' $(< .cap_tasks~) +    IFS=$OLD_IFS +    # zmodload zsh/mapfile +    # _values ${(f)mapfile[.cap_tasks~]}    fi -  compadd `cat .cap_tasks~` -fi +} + +_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 | 
