* PATCH: some repeatable options in completions
@ 2019-09-27 9:40 Oliver Kiddle
2019-09-27 13:49 ` Daniel Shahaf
0 siblings, 1 reply; 3+ messages in thread
From: Oliver Kiddle @ 2019-09-27 9:40 UTC (permalink / raw)
To: Zsh workers
The fact that a particular option can be repeated is easily missed. The
following corrects a few cases that I've come across. In the case of
ssh, multiple -t options force tty allocation, even if ssh has no local
tty. So I'm not sure there's any meaning to specifying it more than
twice but _arguments doesn't provide an easy way to indicate that.
Oliver
diff --git a/Completion/Solaris/Command/_dladm b/Completion/Solaris/Command/_dladm
index cb598de03..5ce9872d2 100644
--- a/Completion/Solaris/Command/_dladm
+++ b/Completion/Solaris/Command/_dladm
@@ -288,7 +288,7 @@ _dladm() {
_arguments -A "-*" \
'(-t --temporary)'{-t,--temporary}'[aggregation should be temporary]' \
'(-R --root)'{-R,--root}'[root directory]:directory:_path_files -/' \
- '(-l --link)'{-l,--link}'[component link]:link:_dladm_links' \
+ \*{-l,--link}'[component link]:link:_dladm_links' \
'(-m --mode)'{-m,--mode}'[aggregation mode]:mode:(dlmp trunk)' \
'(-P --policy)'{-P,--policy}'[port selection policy]:policy:_values -s , "policy" L2 L3 L4' \
'(-L --lacp-mode)'{-L,--lacp-mode}'[LACP mode]:lacp mode:(off active passive)' \
diff --git a/Completion/Unix/Command/_ansible b/Completion/Unix/Command/_ansible
index 3e6a411c3..f1e13a813 100644
--- a/Completion/Unix/Command/_ansible
+++ b/Completion/Unix/Command/_ansible
@@ -49,7 +49,7 @@ case $service in
;|
ansible|ansible-console|ansible-inventory|ansible-playbook|ansible-pull)
args+=(
- '(-i --inventory)'{-i+,--inventory=}'[specify inventory host file or host list]: : _alternative "files\:inventory file\:_files"
+ \*{-i+,--inventory=}'[specify inventory host file or host list]: : _alternative "files\:inventory file\:_files"
"hosts\:host\: _sequence _hosts"'
'!(-i --inventory)--inventory-file=:inventory file:_files'
)
diff --git a/Completion/Unix/Command/_ssh b/Completion/Unix/Command/_ssh
index f8f4e0091..52052a4bb 100644
--- a/Completion/Unix/Command/_ssh
+++ b/Completion/Unix/Command/_ssh
@@ -60,7 +60,7 @@ _ssh () {
'-Q+[query parameters]:query option:((cipher\:"supported symmetric ciphers" cipher-auth\:"supported symmetric ciphers that support authenticated encryption" mac\:"supported message integrity codes" kex\:"key exchange algorithms" key\:"key types" key-cert\:"certificate key types" key-plain\:"non-certificate key types" protocol-version\:"supported SSH protocol versions" sig\:"supported signature algorithms" help\:"show supported queries"))' \
'-s[invoke subsystem]' \
'(-t)-T[disable pseudo-tty allocation]' \
- '(-T)-t[force pseudo-tty allocation]' \
+ '(-T)*-t[force pseudo-tty allocation]' \
'-V[show version number]' \
'(-q)*-v[verbose mode (multiple increase verbosity, up to 3)]' \
'-W+[forward standard input and output to host]:stdinout forward:->hostport' \
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: PATCH: some repeatable options in completions
2019-09-27 9:40 PATCH: some repeatable options in completions Oliver Kiddle
@ 2019-09-27 13:49 ` Daniel Shahaf
2019-09-29 16:00 ` Oliver Kiddle
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Shahaf @ 2019-09-27 13:49 UTC (permalink / raw)
To: Zsh workers
Oliver Kiddle wrote on Fri, 27 Sep 2019 09:40 +00:00:
> ssh, multiple -t options force tty allocation, even if ssh has no local
> tty. So I'm not sure there's any meaning to specifying it more than
> twice but _arguments doesn't provide an easy way to indicate that.
>
(untested) How about:
'(-t -tt)-T[disable pseudo-tty allocation]' \
'(-T)-t[force pseudo-tty allocation]' \
"(-T)-tt[force pseudo-tty allocation even if have no controlling tty]" \
?
> '-s[invoke subsystem]' \
> '(-t)-T[disable pseudo-tty allocation]' \
> - '(-T)-t[force pseudo-tty allocation]' \
> + '(-T)*-t[force pseudo-tty allocation]' \
> '-V[show version number]' \
> '(-q)*-v[verbose mode (multiple increase verbosity, up to 3)]' \
> '-W+[forward standard input and output to host]:stdinout forward:->hostport' \
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: PATCH: some repeatable options in completions
2019-09-27 13:49 ` Daniel Shahaf
@ 2019-09-29 16:00 ` Oliver Kiddle
0 siblings, 0 replies; 3+ messages in thread
From: Oliver Kiddle @ 2019-09-29 16:00 UTC (permalink / raw)
To: Zsh workers
"Daniel Shahaf" wrote:
> Oliver Kiddle wrote on Fri, 27 Sep 2019 09:40 +00:00:
> > ssh, multiple -t options force tty allocation, even if ssh has no local
> > tty. So I'm not sure there's any meaning to specifying it more than
> > twice but _arguments doesn't provide an easy way to indicate that.
> >
>
> (untested) How about:
>
> '(-t -tt)-T[disable pseudo-tty allocation]' \
> '(-T)-t[force pseudo-tty allocation]' \
> "(-T)-tt[force pseudo-tty allocation even if have no controlling tty]" \
There are some cases where we've used that form. The disadvantage is
that it bloats the option/description listing. The shorter it is, the
more chance you have of finding what you're looking for. And given
that -tt will be rare from the command-line rather than a script, I'm
reluctant to add it here in that form. Note that with that form, -tt
should exclude -t and arguably also -t can exclude -tt.
It is also possible to check whether we already have a -t on the command
line and alter the description accordingly. As in the following patch.
The pattern for this has limitations as a t might appear in an argument
to another option. We don't have opt_args before _arguments has been
called.
I also noticed another case of unmarked repeatable options, this time in
_dsh.
Oliver
diff --git a/Completion/Unix/Command/_ssh b/Completion/Unix/Command/_ssh
index f8f4e0091..df1fe6ca8 100644
--- a/Completion/Unix/Command/_ssh
+++ b/Completion/Unix/Command/_ssh
@@ -4,7 +4,7 @@
_ssh () {
local curcontext="$curcontext" state line expl suf ret=1
- local args common common_transfer algopt tmp p1 file cmn cmds sdesc
+ local args common common_transfer algopt tmp p1 file cmn cmds sdesc tdesc
typeset -A opt_args
common=(
@@ -30,6 +30,7 @@ _ssh () {
case "$service" in
ssh)
+ (( $+words[(r)-[^-]#t*] )) && tdesc=' even if there is no controlling tty'
_arguments -C -s \
'(-a)-A[enable forwarding of the authentication agent connection]' \
'(-A)-a[disable forwarding of authentication agent connection]' \
@@ -60,7 +61,7 @@ _ssh () {
'-Q+[query parameters]:query option:((cipher\:"supported symmetric ciphers" cipher-auth\:"supported symmetric ciphers that support authenticated encryption" mac\:"supported message integrity codes" kex\:"key exchange algorithms" key\:"key types" key-cert\:"certificate key types" key-plain\:"non-certificate key types" protocol-version\:"supported SSH protocol versions" sig\:"supported signature algorithms" help\:"show supported queries"))' \
'-s[invoke subsystem]' \
'(-t)-T[disable pseudo-tty allocation]' \
- '(-T)-t[force pseudo-tty allocation]' \
+ "(-T)*-t[force pseudo-tty allocation${tdesc}]" \
'-V[show version number]' \
'(-q)*-v[verbose mode (multiple increase verbosity, up to 3)]' \
'-W+[forward standard input and output to host]:stdinout forward:->hostport' \
diff --git a/Completion/Unix/Command/_dsh b/Completion/Unix/Command/_dsh
index fc7680062..2486b23fd 100644
--- a/Completion/Unix/Command/_dsh
+++ b/Completion/Unix/Command/_dsh
@@ -10,10 +10,10 @@ _arguments -s -C -S \
'(-M --show-machine-names)'{-M,--show-machine-names}'[prepend the host name on output]' \
'(-i --duplicate-input)'{-i,--duplicate-input}'[duplicate input given to dsh]' \
'(-b --bufsize)'{-b,--bufsize}'[change buffer size used in input duplication]:buffer size for -i (bytes)' \
- '(-m --machine)'{-m,--machine}'[execute on machine]:machine:{_hosts || _user_at_host}' \
+ \*{-m,--machine}'[execute on machine]:machine:{_hosts || _user_at_host}' \
'(-n --num-topology)'{-n,--num-topology}'[how to divide the machines]:number' \
'(-a --all)'{-a,--all}'[execute on all machines]' \
- '(-g --group)'{-g,--group}'[execute on group member]:groupname:->groups' \
+ \*{-g,--group}'[execute on group member]:groupname:->groups' \
'(-f --file)'{-f,--file}'[use the file as list of machines]:file:_files' \
'(-r --remoteshell)'{-r,--remoteshell}'[execute using shell]:remote shell:(rsh ssh)' \
'(-o --remoteshellopt)'{-o,--remoteshellopt}'[option to give to remote shell ]:option' \
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-09-29 16:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-27 9:40 PATCH: some repeatable options in completions Oliver Kiddle
2019-09-27 13:49 ` Daniel Shahaf
2019-09-29 16:00 ` Oliver Kiddle
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).