Make zsh completion for upgrade smarter

Closes Homebrew/homebrew#7889.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
This commit is contained in:
Motonori Iwata 2011-09-29 14:35:16 +09:00 committed by Jack Nagel
parent 744ab8fc8c
commit a8437a62ca

View File

@ -14,6 +14,10 @@ _brew_installed_formulae() {
installed_formulae=(`brew list`) installed_formulae=(`brew list`)
} }
_brew_outdated_formulae() {
outdated_formulae=(`brew outdated`)
}
local -a _1st_arguments local -a _1st_arguments
_1st_arguments=( _1st_arguments=(
'cat:display formula file for a formula' 'cat:display formula file for a formula'
@ -36,12 +40,12 @@ _1st_arguments=(
'server:start a local web app that lets you browse formulae (requires Sinatra)' 'server:start a local web app that lets you browse formulae (requires Sinatra)'
'unlink:unlink a formula' 'unlink:unlink a formula'
'update:freshen up links' 'update:freshen up links'
'upgrade:upgrade an installed formula' 'upgrade:upgrade outdated formulae'
'uses:show formulas which depend on a formula' 'uses:show formulas which depend on a formula'
) )
local expl local expl
local -a formulae installed_formulae local -a formulae installed_formulae outdated_formulae
_arguments \ _arguments \
'(-v)-v[verbose]' \ '(-v)-v[verbose]' \
@ -77,7 +81,10 @@ 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|upgrade) remove|rm|uninstall|unlink|cleanup|link|ln)
_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