zsh-workers
 help / color / mirror / code / Atom feed
From: Matthew Martin <phy1729@gmail.com>
To: zsh-workers@zsh.org
Subject: Re: PATCH: doas completion
Date: Sat, 1 Oct 2016 09:31:06 -0500	[thread overview]
Message-ID: <20161001143106.GA11445@CptOrmolo.darkstar> (raw)
In-Reply-To: <80164.1475219190@hydra.kiddle.eu>

On Fri, Sep 30, 2016 at 09:06:30AM +0200, Oliver Kiddle wrote:
> Much of this is just cut and paste from _sudo.
> I think the -a option might be OpenBSD specific: once things settle down
> with a single portable doas implementation instead of the current state
> of there being several then that can be cleaned up.
> 
> Oliver
> 
> diff --git a/Completion/Unix/Command/_doas b/Completion/Unix/Command/_doas
> new file mode 100644
> index 0000000..5c26b1d
> --- /dev/null
> +++ b/Completion/Unix/Command/_doas
> @@ -0,0 +1,18 @@
> +#compdef doas
> +
> +local environ e cmd
> +
> +zstyle -a ":completion:${curcontext}:" environ environ
> +
> +for e in "${environ[@]}"
> +do local -x "$e"
> +done
> +
> +cmd="$words[1]"
> +_arguments -s -S \
> +  '(-n -s)-C+[check config file and report on command matching]:config:_files' \
> +  '(-C)-n[non-interactive: fail rather than prompt for a password]' \
> +  '-a+[specify authentication style]:authentication style' \
> +  '(-C)-s[run a shell]' \
> +  '-u+[run command as specified user]:user:_users' \
> +  '*::arguments:{ _comp_priv_prefix=( $cmd -n ${(kv)opt_args[-u]} ) ; _normal }'

I've had an alternate version sitting in my tree for a while. Merging
the two I get the below. Changes are adding -A '-*' to _arguments,
adding the -L option, sorting options, and ignoring * with -s. I had it
in BSD, but I suppose it's been ported elsewhere now.

- Matthew Martin

diff --git a/Completion/BSD/Command/_doas b/Completion/BSD/Command/_doas
new file mode 100644
index 0000000..b36388e
--- /dev/null
+++ b/Completion/Unix/Command/_doas
@@ -0,0 +1,21 @@
+#compdef doas
+
+local environ e cmd
+
+zstyle -a ":completion:${curcontext}:" environ environ
+
+for e in "${environ[@]}"
+do local -x "$e"
+done
+
+cmd="$words[1]"
+_arguments -s -S -A '-*' : \
+  - optL \
+  '-L[clear any persisted authorizations]' \
+  - default \
+  '-a+[specify authentication style]:authentication style' \
+  '(-n -s)-C+[check config file and report on command matching]:config:_files' \
+  '(-C)-n[non-interactive: fail rather than prompt for a password]' \
+  '(-C *)-s[run a shell]' \
+  '-u+[run command as specified user]:user:_users' \
+  '*::arguments:{ _comp_priv_prefix=( $cmd -n ${(kv)opt_args[-u]} ) ; _normal }'


  reply	other threads:[~2016-10-01 14:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-30  7:06 Oliver Kiddle
2016-10-01 14:31 ` Matthew Martin [this message]
2016-10-01 14:34   ` Matthew Martin

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=20161001143106.GA11445@CptOrmolo.darkstar \
    --to=phy1729@gmail.com \
    --cc=zsh-workers@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).