#compdef equery euse eclean eclean-dist eclean-pkg epkginfo genpkgindex glsa-check revdep-rebuild # ------------------------------------------------------------------------------ # Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of the zsh-users nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------ # Description # ----------- # # Completion script for Gentoolkit (collection of Gentoo administrative scripts). # (Means portage helper python-scrips and some usefull staff) # # ------------------------------------------------------------------------------ # Authors # ------- # # * Vadim A. Misbakh-Soloviev # * Bapt # * kaworu # * David Durrleman # * oberyno # * Mamoru Komachi # # ------------------------------------------------------------------------------ # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------ # # # Status: # euse (fully done) # equery (fully done) # eclean* (fully done) # epkginfo (fully done) # genpkgindex (fully done) # glsa-check (fully done) # revdep-rebuild (fully done) # eread (nothing todo) # XXX: shouldn't this go to _gentoo_package? _packages () { if compset -P '(\\|)(>=|<=|<|>|=)' ; then _gentoo_packages ${*/(#m)(installed|available)/${MATCH}_versions} else _gentoo_packages $* fi } _euse () { local state tmp start_args suboptions_args start_args=( {'(--help)-h','(-h)--help'}'[show help]' {'(--version)-v','(-v)--version'}'[show version]' {'(--info)-i','(-i)--info'}'[show descriptions for the given useflags]' {'(--active)-a','(-a)--active'}'[show currently active useflags and their origin]' {'(--enable)-E','(-E)--enable'}'[enable the given useflags]' {'(--disable)-D','(-D)--disable'}'[disable the given useflags]' {'(--prune)-P','(-P)--prune'}'[show version]' ) suboptions_args=( {'(--global)-g','(-g)--global'}'[show only global use flags]' {'(--local)-l','(-l)--local'}'[show only local use flags]' ) if (( CURRENT == 2 ));then _arguments -s $start_args elif (( CURRENT == 3 ));then case "$words[2]" in -i|--info|-a|--active) _arguments -s $suboptions_args \ '*:useflags:_gentoo_packages useflag' && ret=0 ;; -E|--enable) _arguments \ '*:useflags:_gentoo_packages useflag' && ret=0 ;; -D|--disable) _arguments \ '*:active useflags:_gentoo_packages active_useflag' && ret=0 esac else _arguments \ '*:useflag:_gentoo_packages useflag' && ret=0 fi } _equery () { # Based off of X/_xauth. local state context line expl ret=1 local tmp cmd start_args common_args start_args=( {'(--nocolor)-C','(-C)--nocolor'}'[turns off colors]' {'(--quiet)-q','(-q)--quiet'}'[minimal output]' {'(--help)-h','(-h)--help'}'[show help]' {'(--version)-V','(-V)--version'}'[show version]' ) common_args=( '(-i --installed -I --exclude-installed)'{-i,--installed}'[search installed packages]' '(-I --exclude-installed -i --installed)'{-I,--exclude-installed}'[do not search installed packages]' '(-p --portage)'{-p,--portage-tree}'[also search in portage tree]' '(-o --overlay-tree)'{-o,--overlay-tree}'[also search in overlay tree]' ) _arguments -s $start_args \ '*::command:->command' && ret=0 while [[ -n "$state" ]]; do tmp="$state" state= case "$tmp" in command) if (( CURRENT == 1 )); then state=subcommands else cmd="$words[1]" curcontext="${curcontext%:*:*}:equery-${cmd}:" case "$cmd" in belongs|b) _arguments \ '(-c --category)'{-c,--category}'[only search in specified category]:category:_gentoo_packages category' \ '(-e --earlyout)'{-e,--earlyout}'[stop when first match found]' \ '(-f --full-regex)'{-f,--full-regex}'[supplied query is a full regex]:pattern:' \ '*:file:_files' && ret=0 ;; check|k) _arguments \ ':portage:_packages installed' && ret=0 ;; depends|d) _arguments \ '(-a --all-packages)'{-a,--all-packages}'[search in all available packages (slow)]:all packages:->packages' \ '(-d --direct -D --indirect)'{-d,--direct}'[search direct dependencies only (default)]' \ '(-d --direct -D --indirect)'{-D,--indirect}'[search indirect dependencies (VERY slow)]' \ '*:package:_packages installed' && ret=0 ;; depgraph|g) _arguments \ '(-U --no-useflags)'{-U,--no-useflags}'[do not show USE flags]' \ '(-l --linear)'{-l,--linear}'[do not use fancy formatting]' \ ':package:_packages installed' && ret=0 ;; files|f) _arguments \ '--timestamp[append timestamp]' \ '--md5sum[append md5sum]' \ '--type[prepend file type]' \ '--filter=[filter output]:filter(s):_values -s , '' dir obj sym dev fifo path conf cmd doc man info' \ ':installed pkgname:_packages installed' && ret=0 ;; hasuse|h) _arguments \ $common_args \ ':useflag:_gentoo_packages useflag' && ret=0 ;; list|l) _arguments \ $common_args \ ': :_guard "^--*" pattern' && ret=0 ;; size|s) _arguments \ '(-b --bytes)'{-b,--bytes}'[report size in bytes]' \ ':package:_packages installed' && ret=0 ;; which|w) _arguments \ ':portage:_packages available' && ret=0 ;; uses|u) _arguments \ {--all,-a}'[include non-installed packages]' \ ":portage:_packages installed" && ret=0 ;; *) _message 'command not found' ;; esac fi ;; subcommands) tmp=( {belongs,b}'[list all packages owning file(s)]' {check,k}'[check MD5sums and timestamps of package]' {depends,d}'[list all packages depending on specified package]' {depgraph,g}'[display a dependency tree for package]' {files,f}'[list files owned by package]' {hasuse,h}'[list all packages with specified useflag]' {list,l}'[list all packages matching pattern]' {size,s}'[print size of files contained in package]' {uses,u}'[display USE flags for package]' {which,w}'[print full path to ebuild for package]' ) _values 'equery command' $tmp && ret=0 ;; esac done } _eclean_wrapper () { local global_opts pkg_opts dist_opts global_opts=( '(-C --nocolor)'{-C,--nocolor}'[turns off colors]' '(-d,--destructive)'{-d,--destructive}'[only keep the minimum for a reinstallation]' '(-e,--exclude-file)'{-e,--exclude-file}'[path to the exclusion file]:filename:_files' '(-i,--interactive)'{-i,--interactive}'[ask confirmation before deletions]' '(-n,--package-names)'{-n,--package-names}'[protect all versions (when --destructive)]' '(-p,--pretend)'{-p,--pretend}'[only display what would be cleaned]' '(-q,--quiet)'{-q,--quiet}'[minimal output]' '(-t,--time-limit)'{-t,--time-limit}'[don’t delete files modified since