zsh-users
 help / color / mirror / code / Atom feed
From: Paul Ruane <paul.ruane@oniony.com>
To: Daniel Shahaf <d.s@daniel.shahaf.name>
Cc: zsh-users@zsh.org
Subject: Re: Cryptsetup completion
Date: Wed, 3 Jun 2020 13:52:52 +0100	[thread overview]
Message-ID: <CAJZHWOiszxAafvx=5YbumTdKf2zKonU5pBdzs11tpJk2-Z0Qiw@mail.gmail.com> (raw)
In-Reply-To: <20200603005555.304cca04@tarpaulin.shahaf.local2>

On Wed, 3 Jun 2020 at 01:56, Daniel Shahaf <d.s@daniel.shahaf.name> wrote:

> The helper functions are in the global namespace so they should have
> names that are less likely to clash.  Also, they aren't specific to
> cryptsetup, so we could break them out to separate, autoloadable files

I have renamed these with prefix "_crypto". I noticed commands and
types are now split into their respective directories so I have placed
them accordingly.

> that (you can simply clone the git repository and, for testing, set
> «fpath=( /path/to/zsh/Completions/**/*(/) )» prior to running compinit.).

I was unable to get the fpath with the globbing to work. I ended up
using "fpath=( /home/paul/projects/zsh/Completion )". Even so I had
some errors ("_arguments:comparguments:393: too many arguments")
completing with many commands, not just cryptsetup, but I assume that
this is some incompatibility between my 5.8 and HEAD.

I've used a slightly modified version of Mikael's parameter expansion
to eliminate the need to fork processes.

The new patch--in correct format :)--is here:

diff --git a/Completion/Linux/Command/_cryptsetup
b/Completion/Linux/Command/_cryptsetup
index 45159d0be..3e3bd5ba0 100644
--- a/Completion/Linux/Command/_cryptsetup
+++ b/Completion/Linux/Command/_cryptsetup
@@ -8,8 +8,8 @@ _arguments -s \
   '(-v --verbose)'{-v,--verbose}'[enable verbose mode]' \
   '--debug[show debug messages]' \
   '--debug-json[show debug messages including JSON metadata]' \
-  '(-c --cipher)'{-c+,--cipher=}'[set cipher]:cipher specification' \
-  '(-h --hash)'{-h+,--hash=}'[hash algorithm]:hash algorithm' \
+  '(-c --cipher)'{-c+,--cipher=}'[set cipher]:cipher
specification:_crypto_ciphers' \
+  '(-h --hash)'{-h+,--hash=}'[hash algorithm]:hash algorithm:_crypto_hashes' \
   '(-y --verify-passphrase)'{-y,--verify-passphrase}'[query for
password twice]' \
   '(-d --key-file)'{-d+,--key-file=}'[set keyfile]:key file:_files' \
   '--master-key-file=[set master key]:key file:_files' \
diff --git a/Completion/Linux/Type/_crypto_ciphers
b/Completion/Linux/Type/_crypto_ciphers
new file mode 100644
index 000000000..ab9138a11
--- /dev/null
+++ b/Completion/Linux/Type/_crypto_ciphers
@@ -0,0 +1,7 @@
+#autoload
+
+cipher_list=( ${${${(M)${(s:name:)${(M)${(f)"$(</proc/crypto)"}:#(name|type)*}}:#*:
cipher*}#*: }%% *} )
+
+_describe -t ciphers 'cipher' cipher_list
+
+return ret
diff --git a/Completion/Linux/Type/_crypto_hashes
b/Completion/Linux/Type/_crypto_hashes
new file mode 100644
index 000000000..56b06b5f0
--- /dev/null
+++ b/Completion/Linux/Type/_crypto_hashes
@@ -0,0 +1,7 @@
+#autoload
+
+hash_list=( ${${${(M)${(s:name:)${(M)${(f)"$(</proc/crypto)"}:#(name|type)*}}:#*:
shash*}#*: }%% *} )
+
+_describe -t hashes 'hash' hash_list
+
+return ret

Thanks,
Paul

  parent reply	other threads:[~2020-06-03 12:53 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-02 16:17 Paul Ruane
2020-06-03  0:03 ` Mikael Magnusson
2020-06-03  0:55 ` Daniel Shahaf
2020-06-03 11:19   ` Paul Ruane
2020-06-03 12:52   ` Paul Ruane [this message]
2020-06-04  2:27     ` Daniel Shahaf
2020-06-04 11:50     ` Oliver Kiddle
2020-06-05  1:55       ` Daniel Shahaf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAJZHWOiszxAafvx=5YbumTdKf2zKonU5pBdzs11tpJk2-Z0Qiw@mail.gmail.com' \
    --to=paul.ruane@oniony.com \
    --cc=d.s@daniel.shahaf.name \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).