From c90c27f8fc86cbe361a4b3a5ffcaadebc16337b0 Mon Sep 17 00:00:00 2001 From: Score_Under Date: Thu, 4 Feb 2021 12:12:08 +0000 Subject: [PATCH 1/4] Add completion for gpgconf --- src/_gpgconf | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/_gpgconf diff --git a/src/_gpgconf b/src/_gpgconf new file mode 100644 index 0000000..6909db9 --- /dev/null +++ b/src/_gpgconf @@ -0,0 +1,44 @@ +#compdef gpgconf +# Description: +# Completions for gpgconf (configuration utility provided with GnuPG +# ) +# +# Authors: +# * "score" https://keybase.io/score_under + +_gpgconf_component() { + local values=( + "${(@f)$(gpgconf --list-components \ + | perl -lne 'my ($name, $desc, $x) = split /:/; print "${name}[$desc]"')}" + ) + if [ "${action[2]}" = all ]; then + values+=('all[All daemon components]') + fi + + _values 'component' "${(o)values[@]}" +} + +_arguments \ + '--help[print help text]' \ + '--list-components[list all components]' \ + '--check-programs[check all programs]' \ + '--apply-defaults[apply global default values]' \ + '--list-dirs[get the configuration directories for gpgconf]' \ + '--list-config[list global configuration file]' \ + '--check-config[check global configuration file]' \ + '--query-swdb[query the software version database]' \ + '--reload[reload all or a given component]:component:_gpgconf_component all' \ + '--launch[launch a given component]:component:_gpgconf_component all' \ + '--kill[kill a given component]:component:_gpgconf_component all' \ + '--create-socketdir[create a directory for sockets below /run/user or /var/run/user]' \ + '--remove-socketdir[remove a directory created with command --create-socketdir]' \ + '--list-options[list options]:component:_gpgconf_component' \ + '--change-options[change options]:component:_gpgconf_component' \ + '--check-options[check options]:component:_gpgconf_component' \ + '--apply-profile[update configuration files using the specified file]:configuration file:_path_files' \ + '--status-fd[write status info to the specified file descriptor]:file descriptor' \ + '(-o --output)'{-o,--output}'[write output to the specified file]:output file:_path_files' \ + '(-v --verbose)'{-v,--verbose}'[verbose]' \ + '(-q --quiet)'{-q,--quiet}'[quiet]' \ + '(-n --dry-run)'{-n,--dry-run}'[do not make any changes]' \ + '(-r --runtime)'{-r,--runtime}'[activate changes at runtime, if possible]' From a1d53f88240610d9f45e1a6465f974b9ff12976f Mon Sep 17 00:00:00 2001 From: Score_Under Date: Thu, 4 Feb 2021 14:41:05 +0000 Subject: [PATCH 2/4] Add missing homedir option to _gpgconf --- src/_gpgconf | 1 + 1 file changed, 1 insertion(+) diff --git a/src/_gpgconf b/src/_gpgconf index 6909db9..f8254a5 100644 --- a/src/_gpgconf +++ b/src/_gpgconf @@ -37,6 +37,7 @@ _arguments \ '--check-options[check options]:component:_gpgconf_component' \ '--apply-profile[update configuration files using the specified file]:configuration file:_path_files' \ '--status-fd[write status info to the specified file descriptor]:file descriptor' \ + '--homedir[specify an alternative gnupg configuration home directory]:directory:_directories' \ '(-o --output)'{-o,--output}'[write output to the specified file]:output file:_path_files' \ '(-v --verbose)'{-v,--verbose}'[verbose]' \ '(-q --quiet)'{-q,--quiet}'[quiet]' \ From ab80ddd379777ec2ad3234bd5d0eddef04eb95c2 Mon Sep 17 00:00:00 2001 From: Score_Under Date: Thu, 4 Feb 2021 14:45:30 +0000 Subject: [PATCH 3/4] Shorter perl one-liner in _gpgconf --- src/_gpgconf | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/_gpgconf b/src/_gpgconf index f8254a5..5fe8852 100644 --- a/src/_gpgconf +++ b/src/_gpgconf @@ -8,8 +8,7 @@ _gpgconf_component() { local values=( - "${(@f)$(gpgconf --list-components \ - | perl -lne 'my ($name, $desc, $x) = split /:/; print "${name}[$desc]"')}" + "${(@f)$(gpgconf --list-components | perl -F: -ale 'print "${F[0]}[$F[1]]"')}" ) if [ "${action[2]}" = all ]; then values+=('all[All daemon components]') From 4c5a8ef41e3df7b8f4b5ba43b2d6c5cfaa38e6b2 Mon Sep 17 00:00:00 2001 From: Score_Under Date: Thu, 4 Feb 2021 15:48:07 +0000 Subject: [PATCH 4/4] Add license notice to _gpgconf --- src/_gpgconf | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/_gpgconf b/src/_gpgconf index 5fe8852..7cee03e 100644 --- a/src/_gpgconf +++ b/src/_gpgconf @@ -1,4 +1,29 @@ #compdef gpgconf +# Copyright (c) 2021 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: # Completions for gpgconf (configuration utility provided with GnuPG # )