From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id D6876138350 for ; Wed, 19 Feb 2020 18:48:04 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 95797E0916; Wed, 19 Feb 2020 18:48:03 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 5DACCE0916 for ; Wed, 19 Feb 2020 18:48:03 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id F336434EE00 for ; Wed, 19 Feb 2020 18:48:01 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id ABCA4149 for ; Wed, 19 Feb 2020 18:47:59 +0000 (UTC) From: "Vadim Misbakh-Soloviov" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Vadim Misbakh-Soloviov" Message-ID: <1582138058.b33fbd445ab0014be633d8935ec08d1799900448.mva@gentoo> Subject: [gentoo-commits] proj/zsh-completion:master commit in: src/ X-VCS-Repository: proj/zsh-completion X-VCS-Files: src/_ekeyword src/_eselect X-VCS-Directories: src/ X-VCS-Committer: mva X-VCS-Committer-Name: Vadim Misbakh-Soloviov X-VCS-Revision: b33fbd445ab0014be633d8935ec08d1799900448 X-VCS-Branch: master Date: Wed, 19 Feb 2020 18:47:59 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 03773882-c850-4855-ab4d-c75df001abb3 X-Archives-Hash: abdd7fa1687358df9dc2d21174da3960 commit: b33fbd445ab0014be633d8935ec08d1799900448 Author: Felix Neumärker posteo de> AuthorDate: Wed Feb 19 16:44:18 2020 +0000 Commit: Vadim Misbakh-Soloviov gentoo org> CommitDate: Wed Feb 19 18:47:38 2020 +0000 URL: https://gitweb.gentoo.org/proj/zsh-completion.git/commit/?id=b33fbd44 Merge PR #22 (eselect fixes #22 [PATCH 1/6] _eselect: php-module completion [PATCH 2/6] _eselect: generic uses _describe instead of values [PATCH 3/6] _ekeyword: inital completion [PATCH 4/6] _eselect: news modules - fix order [PATCH 5/6] _eselect: completion for rc module / rc-config [PATCH 6/6] _eselect: repository fixes + options Signed-off-by: Felix Neumärker posteo.de> Signed-off-by: Vadim Misbakh-Soloviov gentoo.org> src/_ekeyword | 23 +++++++++ src/_eselect | 161 ++++++++++++++++++++++++++++++++++++++++++---------------- 2 files changed, 139 insertions(+), 45 deletions(-) diff --git a/src/_ekeyword b/src/_ekeyword new file mode 100644 index 0000000..c86ebb0 --- /dev/null +++ b/src/_ekeyword @@ -0,0 +1,23 @@ +#compdef ekeyword + +local -a arguments=( + '(- :)'{-h,--help}'[Show this help message and exit]' + '(-m --manifest)'{-m,--manifest}'[Run `ebuild manifest` on the ebuild after modifying it]' + '(-n --dry-run)'{-n,--dry-run}'[Show what would be changed, but do not commit]' + '(-v --verbose)'{-v,--verbose}'[Be verbose while processing things]' + '(-q --quiet)'{-q,--quiet}'[Be quiet while processing things (only show errors)]' + '(--format)'--format':Select output format for showing differences:_values -V ekeywordsfmt "ekeywords formats" auto color-inline inline short-multi long-multi' + '(- :)'{-V,--version}'[Show version information]' +) + +(( $+functions[_ekeywordargs] )) || _ekeywordargs() { + _files -g \*.ebuild + + local -a keywords=(all $(_gentoo_arches)) + + compset -P '(\^|\~)' + _values -V "keywords" "gentoo arches" ${keywords[@]} +} + +_arguments ${arguments[@]} "*:ekeywordargs:_ekeywordargs" + diff --git a/src/_eselect b/src/_eselect index 77b9fd6..ce185a8 100644 --- a/src/_eselect +++ b/src/_eselect @@ -45,25 +45,24 @@ _eselect_parse_generic() { } _eselect_parse_action_list() { - local eselect_list - local idx descr - local arr_items_selected=$2 - local arr_items_unselected=$3 - - eselect_list="$(LANG=C COLUMNS=100 eselect --colour=no $1 list 2> /dev/null)" - while IFS="" read -r ele ; do - echo "$ele" | read idx descr - idx=${idx#*\[} - idx=${idx%\]*} - if [[ "$idx" =~ '^[0-9]+$' ]]; then - local stripped_descr="${descr% *\**}" - if [[ "${stripped_descr}" != "${descr}" ]] ; then - set -A $arr_items_selected ${(P)arr_items_selected} "$idx:${(q)descr}" - else - set -A $arr_items_unselected ${(P)arr_items_unselected} "$idx:${(q)descr}" - fi + local idx item tag + local -a _sel_items + local -a _unsel_items + + while read idx item tag descr ; do + if [[ "$idx" == '[' && "$item" == ']' ]] ; then + continue + fi + if [[ ${tag} =~ '^[*@#]$' ]] ; then + _sel_items+=($item) + else + _unsel_items+=($item) fi - done <<< "$eselect_list" + done <<< $(LANG=C COLUMNS=100 eselect --colour=no $1 list 2> /dev/null | tail -n +2) + + set -A $2 ${_sel_items[@]} + set -A $3 ${_unsel_items[@]} + } _eselect_module_action() { @@ -78,9 +77,15 @@ _eselect_complete_action() { local actionname=$(_eselect_get_module) if (( $+functions[_eselect_complete_${actionname}_action] )) ; then _eselect_complete_${actionname}_action - else + return 0 + fi + + if (( $NORMARG + $(_eselect_action_index) == $CURRENT )) ; then _eselect_complete_action_generic ${actionname} + return 0 fi + + _nothing } _eselect_get_module() { @@ -110,31 +115,29 @@ _eselect_module() { _eselect_parse_generic } -_eselect_complete_action_generic() { +(( $+function[_eselect_complete_action_generic] )) || _eselect_complete_action_generic() { local -a sel_items local -a unsel_items - if (( $NORMARG + $(_eselect_action_index) == $CURRENT )) ; then - case "$(_eselect_get_action)" in - ("set"|"enable")) - _eselect_parse_action_list $1 sel_items unsel_items - if (( $#unsel_items + $#sel_items > 0 )) ; then - _describe -t eselect_sel -V 'eselect items' unsel_items - if (( $#unsel_items + $#sel_items < 10 )) ; then - _describe -t eselect_unsel -V 'eselect already selected items' sel_items - fi - return 0 - fi - ;; - ("remove"|"disable")) - _eselect_parse_action_list $1 sel_items unsel_items - if [[ -n "${sel_items[@]}" ]] ; then - _describe -V 'eselect items' sel_items - return 0 + case "$(_eselect_get_action)" in + ("set"|"enable")) + _eselect_parse_action_list $1 sel_items unsel_items + if (( $#unsel_items + $#sel_items > 0 )) ; then + _describe -t eselect_sel -V 'eselect items' unsel_items + if (( $#unsel_items + $#sel_items < 10 )) ; then + _describe -t eselect_unsel -V 'eselect already selected items' sel_items fi - ;; - esac - fi + return 0 + fi + ;; + ("remove"|"disable")) + _eselect_parse_action_list $1 sel_items unsel_items + if [[ -n "${sel_items[@]}" ]] ; then + _describe -V 'eselect items' sel_items + return 0 + fi + ;; + esac _nothing } @@ -145,15 +148,19 @@ _eselect_complete_action_generic() { case "$(_eselect_get_action)" in ("read"|"unread")) - local -a extra_items=('all:Read all news items') + local idx descr + while read idx descr ; do + idx=${idx#'['} + idx=${idx%']'} + items=(${idx}:${(q)descr} ${items[@]}) + done <<< $(eselect --colour=no news list 2> /dev/null | tail -n +2) + items+=('all:Read all news items') if [[ $(_eselect_get_action) == "read" ]] ; then - extra_items=('new:Read unread news items (default)' "${extra_items[@]}") + items+=('new:Read unread news items (default)') fi - _eselect_parse_action_list news items items - items=(${(q)extra_items[@]} ${(Oa)items}) if [[ -n "${items[@]}" ]] ; then - _describe -V 'eselect items' items + _describe -V 'eselect news' items return 0 fi ;; @@ -207,6 +214,70 @@ _eselect_complete_action_generic() { _nothing } +(( $+functions[_eselect_complete_php_action] )) || _eselect_complete_php_action() { + if (( $NORMARG + $(_eselect_action_index) == $CURRENT )) ; then + case "$(_eselect_get_action)" in + ("list"|"set"|"show"|"update")) + _values 'eselect php modules' $(eselect --colour=no --brief php list-modules) + return 0 + ;; + esac + elif (( $NORMARG + $(_eselect_action_index) + 1 == $CURRENT )) ; then + case "$words[$CURRENT-2]" in + "set") + local targets=($(eselect --colour=no --brief php list "$words[$CURRENT-1]" 2> /dev/null)) + if [ -n "$targets" ]; then + _values 'eselect php modules' ${targets[@]} + return 0 + fi + ;; + esac + fi + + _nothing +} + +(( $+functions[_eselect_complete_rc_action] )) || _eselect_complete_rc_action() { + if (( $NORMARG + $(_eselect_action_index) == $CURRENT )) ; then + case "$(_eselect_get_action)" in + ("list"|"show")) + _values 'runlevels' $(command ls --color=never ${EPREFIX}/etc/runlevels) + return 0 + ;; + ("add"|"delete"|"pause"|"reload"|"restart"|"start"|"stop")) + _values 'scripts' $(rc-service -l) + return 0 + ;; + esac + elif (( $NORMARG + $(_eselect_action_index) + 1 == $CURRENT )) ; then + case "$words[$CURRENT-2]" in + ("add"|"delete")) + _values 'runlevels' $(command ls --color=never ${EPREFIX}/etc/runlevels) + return 0 + ;; + esac + fi + + _nothing +} + + +(( $+functions[_eselect_complete_repository_action] )) || _eselect_complete_repository_action() { + local -a opts + + case "$(_eselect_get_action)" in + ("disable"|"remove")) + opts=('-f:Force potentially dangerous removals') + ;; + "list") + opts=('-i:Only list installed') + ;; + esac + + _describe -o 'options' opts + _eselect_complete_action_generic repository +} + eselect_comp() { integer NORMARG