Add remote argument completions
This was copied from _git-flow
This commit is contained in:
parent
4ed5855317
commit
d5674edf44
33
src/_heroku
33
src/_heroku
|
@ -163,9 +163,40 @@ case "$words[1]" in
|
|||
_arguments \
|
||||
$_command_args \
|
||||
'(-a|--app)'{-a,--app}'[the app name]' \
|
||||
'(-r|--remote)'{-r,--remote}'[the git remote name]' \
|
||||
'(-r|--remote)'{-r,--remote}'[the git remote name]:remote:->remotes' \
|
||||
&& return 0
|
||||
|
||||
__git_remotes () {
|
||||
local expl gitdir remotes
|
||||
|
||||
gitdir=$(_call_program gitdir git rev-parse --git-dir 2>/dev/null)
|
||||
__git_command_successful || return
|
||||
|
||||
remotes=(${${(f)"$(_call_program remotes git config --get-regexp '"^remote\..*\.url$"')"}//#(#b)remote.(*).url */$match[1]})
|
||||
__git_command_successful || return
|
||||
|
||||
# TODO: Should combine the two instead of either or.
|
||||
if (( $#remotes > 0 )); then
|
||||
_wanted remotes expl remote compadd $* - $remotes
|
||||
else
|
||||
_wanted remotes expl remote _files $* - -W "($gitdir/remotes)" -g "$gitdir/remotes/*"
|
||||
fi
|
||||
}
|
||||
|
||||
__git_command_successful () {
|
||||
if (( ${#pipestatus:#0} > 0 )); then
|
||||
_message 'not a git repository'
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
case $state in
|
||||
(remotes)
|
||||
__git_remotes && return 0
|
||||
;;
|
||||
esac
|
||||
|
||||
# Local Variables:
|
||||
# mode: Shell-Script
|
||||
# sh-indentation: 2
|
||||
|
|
Loading…
Reference in New Issue