_brew update

1. use _call_program
2. formulae completion for search
3. formulae completion for upgrade
4. add pin/unpin command
This commit is contained in:
Zhao Cai 2013-04-11 11:33:42 -04:00
parent 5a4ab02e40
commit 3ebbd136df
1 changed files with 21 additions and 5 deletions

View File

@ -23,11 +23,15 @@
_brew_all_formulae() { _brew_all_formulae() {
formulae=(`brew search`) # FIXME _call_program should be used here formulae=(${(f)"$(_call_program formulae brew search 2>/dev/null)"})
} }
_brew_installed_formulae() { _brew_installed_formulae() {
installed_formulae=(`brew list`) # FIXME _call_program should be used here installed_formulae=(${(f)"$(_call_program formulae brew list 2>/dev/null)"})
}
_brew_outdated_formulae() {
outdated_formulae=(${(f)"$(_call_program formulae brew outdated 2>/dev/null)"})
} }
local -a _1st_arguments local -a _1st_arguments
@ -58,6 +62,7 @@ _1st_arguments=(
'test:a few formulae provide a test method' 'test:a few formulae provide a test method'
'unlink:unlink a formula' 'unlink:unlink a formula'
'untap:remove a tapped repository' 'untap:remove a tapped repository'
'unpin:unpin specified formulae'
'update:freshen up links' 'update:freshen up links'
'upgrade:upgrade outdated formulae' 'upgrade:upgrade outdated formulae'
'uses:show formulae which depend on a formula' 'uses:show formulae which depend on a formula'
@ -65,7 +70,7 @@ _1st_arguments=(
) )
local expl local expl
local -a formulae installed_formulae local -a formulae installed_formulae outdated_formulae
_arguments \ _arguments \
'(-v)-v[verbose]' \ '(-v)-v[verbose]' \
@ -87,10 +92,17 @@ case "$words[1]" in
search|-S) search|-S)
_arguments \ _arguments \
'(--macports)--macports[search the macports repository]' \ '(--macports)--macports[search the macports repository]' \
'(--fink)--fink[search the fink repository]' ;; '(--fink)--fink[search the fink repository]' \
'1: :->forms' && return 0
if [[ "$state" == forms ]]; then
_brew_all_formulae
_wanted formulae expl 'all formulae' compadd -a formulae
fi ;;
list|ls) list|ls)
_arguments \ _arguments \
'(--unbrewed)--unbrewed[files in brew --prefix not controlled by brew]' \ '(--unbrewed)--unbrewed[files in brew --prefix not controlled by brew]' \
'(--pinned)--pinned[list all versions of pinned formulae]' \
'(--versions)--versions[list all installed versions of a formula]' \ '(--versions)--versions[list all installed versions of a formula]' \
'1: :->forms' && return 0 '1: :->forms' && return 0
@ -101,9 +113,12 @@ case "$words[1]" in
install|home|homepage|log|info|abv|uses|cat|deps|edit|options) install|home|homepage|log|info|abv|uses|cat|deps|edit|options)
_brew_all_formulae _brew_all_formulae
_wanted formulae expl 'all formulae' compadd -a formulae ;; _wanted formulae expl 'all formulae' compadd -a formulae ;;
remove|rm|uninstall|unlink|cleanup|link|ln|test) remove|rm|uninstall|unlink|cleanup|link|ln|pin|unpin|test)
_brew_installed_formulae _brew_installed_formulae
_wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae ;; _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae ;;
upgrade)
_brew_outdated_formulae
_wanted outdated_formulae expl 'outdated formulae' compadd -a outdated_formulae ;;
esac esac
# Local Variables: # Local Variables:
@ -113,3 +128,4 @@ esac
# sh-basic-offset: 2 # sh-basic-offset: 2
# End: # End:
# vim: ft=zsh sw=2 ts=2 et # vim: ft=zsh sw=2 ts=2 et