diff options
-rw-r--r-- | AUTHORS | 3 | ||||
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | zsh-completion/Makefile.am | 8 | ||||
-rw-r--r-- | zsh-completion/_adjutrix | 57 | ||||
-rw-r--r-- | zsh-completion/_paludis | 106 | ||||
-rw-r--r-- | zsh-completion/_paludis_packages | 60 |
7 files changed, 236 insertions, 1 deletions
@@ -37,3 +37,6 @@ Piotr Rak <piotr.rak@gmail.com> Richard Brown <mynamewasgone@gmail.com> Contributor +Baptiste Daroussin <baptux@free.fr> + Contributor, zsh completion + diff --git a/Makefile.am b/Makefile.am index af9dfbdc2..49acab62f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,7 +4,7 @@ MAINTAINERCLEANFILES = Makefile.in configure config/* aclocal.m4 \ config.h config.h.in INSTALL COPYING AUTOMAKE_OPTIONS = dist-bzip2 no-dist-gzip std-options EXTRA_DIST = autogen.bash automake-deps-dist-hack.tmp -SUBDIRS = misc test paludis cran ebuild ruby src doc hooks eselect bash-completion +SUBDIRS = misc test paludis cran ebuild ruby src doc hooks eselect bash-completion zsh-completion DISTCHECK_CONFIGURE_FLAGS = --enable-qa --enable-ruby --enable-glsa \ --with-ruby-install-dir='$${DESTDIR}$${prefix}/ruby_dir' diff --git a/configure.ac b/configure.ac index 4ae92e734..e65a2616f 100644 --- a/configure.ac +++ b/configure.ac @@ -798,6 +798,7 @@ AC_OUTPUT( src/qualudis/Makefile src/adjutrix/Makefile test/Makefile + zsh-completion/Makefile ) dnl }}} diff --git a/zsh-completion/Makefile.am b/zsh-completion/Makefile.am new file mode 100644 index 000000000..3f78d6558 --- /dev/null +++ b/zsh-completion/Makefile.am @@ -0,0 +1,8 @@ +MAINTAINERCLEANFILES = Makefile.in +noinst_DATA = _paludis _adjutrix _paludis_packages +EXTRA_DIST = $(noinst_DATA) + +built-sources : $(BUILT_SOURCES) + for s in $(SUBDIRS) ; do $(MAKE) -C $$s built-sources || exit 1 ; done + + diff --git a/zsh-completion/_adjutrix b/zsh-completion/_adjutrix new file mode 100644 index 000000000..a2bcbcd41 --- /dev/null +++ b/zsh-completion/_adjutrix @@ -0,0 +1,57 @@ +#compdef adjutrix + +# vim: set et sw=4 sts=4 ts=4 ft=zsh : +# ZSH completion for adjutrix +# Written by Baptiste Daroussin <baptux at free.fr> + +_adjutrix() { + local actions tree_options profile_options general_options actions_args arches + actions=( + --find-stable-candidates -s + --find-dropped-keywords -d + --find-insecure-packages -i + --keyword-graph -k + --reverse-deps -r + --display-profiles-use -u + --display-default-system-resolution -S + --version -V + --help -h + ) + arches=(alpha amd64 arm hppa ia64 m68k mips ppc ppc64 ppc-macos s390 sh sparc sparc-fbsd x86 x86-fbsd) + tree_options=( + '(--category -C)'{--category,-C}'[Matches with this category name only (may be specified multiple times)]:Category:' + '(--package -P)'{--package,-P}'[Matches with this package name only (may be specified multiple times)]:Packages:' + ) + profile_options=( + '(--profile -p)'{--profile,-p}'[Display results for this profile path, rather than all profiles (may be specified multiple times)]:Profile:_files -/' + '(--unstable -U)'{--unstable,-U}'[Accept ~arch as well as arch]' + ) + general_options=( + '--log-level[Specify the log level]:log level:((debug\:Show\ debug\ output qa\:Show\ QA\ messages\ and\ warnings\ only warning\:Show\ warnings\ only silent\:Suppress\ all\ log\ messages))' + '(--no-colour --no-color)'{--no-colour,--no-color}"[Do not use colour]" + '(--repository-dir -D)'{--repository-dir,-D}'[Where to find the repository]:repository:_files -/' + ) + action_args=( + "($actions)"{--find-stable-candidates,-s}"[Search for stable package candidates]:arch:($arches)" + "($actions)"{--find-dropped-keywords,-d}"[Search for packages where keywords have been dropped]:arch:($arches)" + "($actions)"{--find-insecure-packages,-i}"[Search for packages marked as insecure by a GLSA]" + "($actions)"{--keyword-graph,-k}"[Display keywords graphically]" + "($actions)"{--reverse-deps,-r}"[all package that depend on a given dep atom]:Packages:" + "($actions)"{--display-profiles-use,-u}"[Display USE information for all profiles]" + "($actions)"{--display-default-system-resolution,-S}"[Display package names and versions that are included in the default resolution of the system set]" + "(: -)"{--version,-V}"[Display program version]" + "(: -)"{--help,-h}"[Display program help]" + ) + if (( $words[(I)(--(find-stable-candidates|find-dropped-keywords|find-insecure-packages|keyword-graph|reverse-deps)|-[[:alpha:]]#(s|d|i|k|r)[[:alpha:]]#)] ));then + _arguments -s \ + $general_options[@] $tree_options[@] && return 0 + elif (( $words[(I)(--(display-profiles-use|display-default-system-resolution)|-[[:alpha:]]#(u|S)[[:alpha:]]#)] ));then + _arguments -s \ + $general_options[@] $profile_options[@] && return 0 + else + _arguments -s \ + $general_options[@] $profile_options[@] $tree_options[@] $action_args[@] && return 0 + fi +} + +_adjutrix "$@" diff --git a/zsh-completion/_paludis b/zsh-completion/_paludis new file mode 100644 index 000000000..9f057ef24 --- /dev/null +++ b/zsh-completion/_paludis @@ -0,0 +1,106 @@ +#compdef paludis + +# vim: set et sw=4 sts=4 ts=4 ft=zsh : +# ZSH completion for adjutrix +# Written by Baptiste Daroussin <baptux at free.fr> + +_paludis() { + local actions action_args query_args general_args deplist_args install_uninstall_args list_args lists + actions=( --query --install -i --uninstall -u --sync -s --report --contents -k --owner -o --version -V --info -I --help -h \ + --has-version --best-version --environnement-variable --list-repositories --list-categories --list-packages --list-sets --list-sync-protocols --list-repository-formats --list-dep-tag-categories --regenerate-installed-cache --update-news --regenerate-installable-cache) + + query_args=( + '(--show-deps -D)'{--show-deps,-D}"[Show dependencies]" + '(--show-metadata -M)'{--show-metadata,-M}"[Show raw metadata]" + ) + + install_uninstall_args=( + '(--pretend -p)'{--pretend,-p}"[Pretend only]" + '(--preserve-world -1)'{--preserve-world,-1}"[Don t modify the world file]" + '--no-config-protection[Disable config file protection (dangerous)]' + '--debug-build[What to do with debug information]:Debug Build:(( none\:Discard\ debug\ information split\:Split\ debug\ information internal\:Keep\ debug\ information\ with\ binaries ))' + '(--fetch -f)'{--fetch,-f}'[Only fetch sources; don t install anything]' + '--show-install-reasons[Show why packages are being installed]:Verbosity:((none\:Don\ t\ show\ any\ information summary\:Show\ a\ summary full\:Show\ full\ output))' + '--with-unused-dependencies[Also uninstall any dependencies of the target that are no longer used]' + '--with-dependencies[Also uninstall packages that depend upon the target]' + ) + list_args=( + '--repository[Matches with this repository name only]:repository:_paludis_packages repositories' + '--category[Matches with this category name only]:category:_paludis_packages category' + '--package[Matches with this package name only]:package:_paludis_packages available' + '--set[Matches with this package set name only]:set:_paluldis_packages set' + ) + + lists=( + '(: -)--list-repositories[List available repositories]' + '(: -)--list-categories[List available categories]' + '(: -)--list-packages[List available packages]' + '(: -)--list-sets[List available package sets]' + '(: -)--list-sync-protocols[List available sync protocols]' + '(: -)--list-repository-formats[List available repository formats]' + '(: -)--list-dep-tag-categories[List known dep tag categories]' + ) + general_args=( + '--log-level[Specify the log level]:log level:((debug\:Show\ debug\ output qa\:Show\ QA\ messages\ and\ warnings\ only warning\:Show\ warnings\ only silent\:Suppress\ all\ log\ messages))' + '(--no-colour --no-color)'{--no-colour,--no-color}"[Do not use colour]" + '(--config-suffix -c)'{-c,--config-suffix}"[Config directory suffix]" + ) + + action_args=( + "($actions)"{-q,--query}"[Query for package information]" + "($actions)"{-i,--install}"[Install one or more packages]" + "($actions)"{-u,--uninstall}"[Uninstall one or more packages]" + "(: -)"{--sync,-s}"[Sync all or specified repositories]:repository:_paludis_packages repositories" + "($actions)--uninstall-unused[Uninstall unused packages]" + "(: -)"{--report,-r}"[Report the current state of the system]" + "(: -)"{--contents,-k}"[Display contents of a package]:package:_paludis_packages installed" + "(: -)"{--owner,-o}"[Display the owner of a file]:File:_files" + "(: -)"{--version,-V}"[Display program version]" + "(: -)"{--info,-I}"[Display program version and system information]" + "(: -)"{--help,-h}"[Display program help]" + "(: -)--has-version[Check whether the specified atom is installed]:package:_paludis_packages available" + "(: -)--best-version[Display the best version of the specified atom]:package _paludis_packages available" + "(: -)--environment-variable[Display the value of an environment variable for a particular package]:package:_paludis_packages available" + "(: -)--configuration-variable[Display the value of a configuration variable for a particular repository]:_paludis_packages repositories" + "(: -)--update-news[Regenerate news.unread files]" + "(: -)--regenerate-installed-cache[Regenerate (non-metadata) cache for installed repositories]" + "(: -)--regenerate-installable-cache[Regenerate (non-metadata) cache for installable repositories]" + ) + deplist_args=( + "--dl-reinstall[When to reinstall packages]:When:(never always if-use-changed)" + "--dl-reinstall-scm[When to reinstall scm packages]:When:(never always daily weekly)" + "--dl-upgrade[When to upgrade packages]:When:(always as-needed)" + "--dl-installed-deps-pre[How to handle pre dependencies for installed packages]:How:(pre pre-or-post post try-post discard)" + "--dl-installed-deps-runtime[How to handle runtime dependencies for installed packages]:How:(pre pre-or-post post try-post discard)" + "--dl-installed-deps-post[How to handle post dependencies for installed packages]:How:(pre pre-or-post post try-post discard)" + "--dl-uninstalled-deps-pre[How to handle pre dependencies for uninstalled packages]:How:(pre pre-or-post post try-post discard)" + "--dl-uninstalled-deps-post[How to handle post dependencies for uninstalled packages]:How:(pre pre-or-post post try-post discard)" + "--dl-circular[How to handle circular dependencies]:How:(error discard)" + "--dl-fall-back[When to fall back to installed packages]:When:(as-needed-except-targets as-needed never)" + ) + #dispatch + if (( $words[(I)(--(uninstall)|-[[:alpha:]]#(u)[[:alpha:]]#)] )) ; then + _arguments -s \ + $general_args[@] $deplist_args[@] $install_uninstall_args[@] \ + "*:installed package:_paludis_packages installed" && return 0 + elif (( $words[(I)--uninstall-unused] )) ; then + _arguments -s \ + $deplist_args[@] $install_uninstall_args[@] && return 0 + elif (( $words[(I)(--(install)|-[[:alpha:]]#(i)[[:alpha:]]#)] )) ;then + _arguments -s \ + $general_args[@] $deplist_args[@] $install_uninstall_args[@] \ + "*:available packages:_paludis_packages available" && return 0 + elif (( $words[(I)(--(query)|-[[:alpha:]]#(q)[[:alpha:]]#)] )) ;then + _arguments -s \ + $general_args[@] $query_args[@]\ + "*:available packages:_paludis_packages available" && return 0 + elif (( $words[(I)--(repository|package|category|set)] ));then + _arguments \ + $lists[@] && reruen 0 + else + _arguments -s \ + $general_args[@] $deplist_args[@] $list_args[@] $lists[@] $install_uninstall_args[@] "$action_args[@]" && return 0 + fi +} + +_paludis "$@" diff --git a/zsh-completion/_paludis_packages b/zsh-completion/_paludis_packages new file mode 100644 index 000000000..ba5d7d3fb --- /dev/null +++ b/zsh-completion/_paludis_packages @@ -0,0 +1,60 @@ +#autoload + +# vim: set et sw=4 sts=4 ts=4 ft=zsh : +# ZSH completion utility functions for paludis +# Written by Baptiste Daroussin <baptux at free.fr> +# Usage: _paludis_packages installed|available|repositories|categories|sets + +local flags prepo packages categories +_paludis_packages_update_available() { + categories=(${${(M)${(f)"$(paludis --list-categories)"}:#\* *}##\* }) + if [[ $PREFIX != */* ]];then + _wanted cat_packages expl "category/packages" compadd -S "/" $categories + else + compset -P '*/' +# packages=(${${(M)${(f)"$(paludis --category ${PREFIX//\//} --list-packages)"}:#\* *}##\* }) + packages=(${${${(M)${(f)"$(paludis --category ${IPREFIX//\//} --list-packages)"}:#\* *}##\* }//$IPREFIX/}) + _wanted cat_packages expl "category/packages" compadd ${(@)packages} + fi +} + +_paludis_packages_update_installed() { + packages=(${${(M)${(f)"$(paludis --repository installed --list-packages)"}:#\* *}##\* }) + + compadd ${(@)packages} +} +_paludis_packages_update_categories() { + packages=(${${${(M)${(f)"$(paludis --list-categories)"}:#\* *}##\* }:#*(virtual|installed)*}) + compadd ${(@)packages} +} +_paludis_packages_update_repositories() { + packages=(${${${(M)${(f)"$(paludis --list-repositories)"}:#\* *}##\* }:#*(virtual|installed)*}) + compadd ${(@)packages} +} +_paludis_packages_update_sets() { + packages=(${${${(M)${(f)"$(paludis --list-sets)"}:#\* *}##\* }:#*(virtual|installed)*}) + compadd ${(@)packages} +} +_paludis_packages() { + local command="$argv[$#]" expl cachevar pkgset update_policy + zstyle -s ":completion:*:*:$service:*" cache-policy update_policy + if [[ -z "$update_policy" ]]; then + zstyle ":completion:*:*:$service:*" cache-policy _paludis_cache_policy + fi + [[ "$command" == (installed|available|categories|repositories|sets) ]] || { + _message "unknown command: $command" + return + } + [[ "$pkgset" == (installed|available|categories|repositories|sets) ]] || { + pkgset="$command" + } + expl=("${(@)argv[1,-2]}") + _paludis_packages_update_$pkgset +} +_paludis_cache_policy () { +# rebuild if cache is more than a week old + oldp=( "$1"(mw+1) ) + (( $#oldp )) && return 0 +} + +_paludis_packages "$@" |