2016-08-19 11:44:06 -05:00
|
|
|
#compdef brew-cask
|
|
|
|
#autoload
|
|
|
|
|
|
|
|
# Autocompletion for homebrew-cask (https://github.com/caskroom/homebrew-cask/).
|
|
|
|
#
|
|
|
|
# Originally sourced from the oh-my-zsh
|
|
|
|
# https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/brew-cask/brew-cask.plugin.zsh
|
|
|
|
#
|
|
|
|
# The MIT License (MIT)
|
|
|
|
#
|
|
|
|
# Copyright (c) 2009-2016 Robby Russell and contributors
|
|
|
|
# See the full list at https://github.com/robbyrussell/oh-my-zsh/contributors
|
|
|
|
#
|
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
# of this software and associated documentation files (the "Software"), to deal
|
|
|
|
# in the Software without restriction, including without limitation the rights
|
|
|
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
# copies of the Software, and to permit persons to whom the Software is
|
|
|
|
# furnished to do so, subject to the following conditions:
|
|
|
|
#
|
|
|
|
# The above copyright notice and this permission notice shall be included in all
|
|
|
|
# copies or substantial portions of the Software.
|
|
|
|
#
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
# SOFTWARE.
|
|
|
|
|
|
|
|
__brew_all_casks() {
|
2016-08-19 12:06:59 -05:00
|
|
|
local -a list
|
|
|
|
local expl
|
|
|
|
list=( $(brew cask search) )
|
|
|
|
_wanted list expl 'all casks' compadd -a list
|
2016-08-19 11:44:06 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
__brew_installed_casks() {
|
2016-08-19 12:06:59 -05:00
|
|
|
local -a list
|
|
|
|
local expl
|
|
|
|
list=( $(brew cask list|sed 's/(!)//') )
|
|
|
|
_wanted list expl 'installed casks' compadd -a list
|
2016-08-19 11:44:06 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
_brew_cask()
|
|
|
|
{
|
|
|
|
local curcontext="$curcontext" state state_descr line
|
|
|
|
typeset -A opt_args
|
|
|
|
|
|
|
|
_arguments -C \
|
|
|
|
':subcmd:->subcmd' \
|
|
|
|
'*::options:->options'
|
|
|
|
|
|
|
|
case $state in
|
|
|
|
(subcmd)
|
|
|
|
local -a subcommands
|
|
|
|
subcommands=(
|
|
|
|
'audit:verifies installability of Casks'
|
|
|
|
'cat:dump raw source of the given Cask to the standard output'
|
|
|
|
'cleanup:cleans up cached downloads and tracker symlinks'
|
|
|
|
'create:creates the given Cask and opens it in an editor'
|
|
|
|
'doctor:checks for configuration issues'
|
|
|
|
'edit:edits the given Cask'
|
|
|
|
'fetch:downloads remote application files to local cache'
|
|
|
|
'home:opens the homepage of the given Cask'
|
|
|
|
'info:displays information about the given Cask'
|
|
|
|
'install:installs the given Cask'
|
|
|
|
'list:with no args, lists installed Casks; given installed Casks, lists staged files'
|
|
|
|
'search:searches all known Casks'
|
|
|
|
'style:checks Cask style using RuboCop'
|
|
|
|
'uninstall:uninstalls the given Cask'
|
|
|
|
"update:a synonym for 'brew update'"
|
|
|
|
'zap:zaps all files associated with the given Cask'
|
|
|
|
)
|
|
|
|
_describe -t commands "brew cask subcommand" subcommands ;;
|
|
|
|
(options)
|
|
|
|
case "$line[1]" in
|
|
|
|
list|uninstall)
|
2016-08-19 12:06:59 -05:00
|
|
|
__brew_installed_casks ;;
|
2016-08-19 11:44:06 -05:00
|
|
|
audit|cat|edit|fetch|home|info|install|zap)
|
2016-08-19 12:06:59 -05:00
|
|
|
__brew_all_casks ;;
|
2016-08-19 11:44:06 -05:00
|
|
|
esac ;;
|
|
|
|
esac
|
|
|
|
}
|