From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: zsh workers <zsh-workers@zsh.org>
Subject: Re: zsh virsh completion
Date: Tue, 12 Jul 2016 00:07:50 +0200 [thread overview]
Message-ID: <16122.1468274870@hydra.kiddle.eu> (raw)
In-Reply-To: <8eb6dce0-50d7-5ab2-503a-194c1de2e45d@redhat.com>
Marko Myllynen wrote:
> Below is a patch to implement basic completion for the virsh(1) [1]
> command from libvirt [2], it completes all virsh commands and their
> respective options.
The function should probably be named _libvirt then - in much the same
way as we use e.g. _subversion for svn.
> - virsh help <command> output is pretty much like --help output of any
> other program, is there a trick to make the option descriptions also
> available when completing virsh command options?
If you don't use _arguments --, you can parse the output manually.
> - would it make sense (or is it perhaps already possible somehow) to
> optionally enable "best guess" completion for all commands which have
> no command specific completion rules available yet? There are lots of
There are commands where running the command with --help/-h or
whatever could do something destructive. I forget which command it
was but I remember years ago finding that a completion was spewing
messages into syslog. If it was going to be a catch-all default,
it might be safer to use man pages as the source.
> +_arguments -A "-*" -C -S -s -w \
-w, really? That's rare.
> + _cache_virsh_cmds=( ${="$(virsh help 2>&1 | awk '!/:/ {print $1}')"} )
You should use _call_program as a wrapper around virsh.
> + _values -w options ${=_cache_virsh_cmdopts[$cmd]} && ret=0
I'm not convinced that _values is gaining you anything over a plain
compadd (with _wanted). I wouldn't typically use it with generated
matches. If you want the duplicate removal, use -F words
With this in place there's no filename completion which can be quite
annoying if you need to complete files. So unless virsh sub-commands
never take filenames as arguments, I'd have it fallback to _default.
In this case, using _alternative. Also, for option completion, it
should check the prefix-needed style.
Oliver
next prev parent reply other threads:[~2016-07-11 22:14 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-11 11:52 Marko Myllynen
2016-07-11 15:03 ` Roman Neuhauser
2016-07-11 16:40 ` Bart Schaefer
2016-07-11 22:07 ` Oliver Kiddle [this message]
2016-07-12 10:23 ` Marko Myllynen
2016-07-13 4:59 ` Daniel Shahaf
2016-07-18 12:06 ` Marko Myllynen
2016-07-20 6:58 ` [PATCH] _virsh (Was: Re: zsh virsh completion) Daniel Shahaf
2016-07-20 8:36 ` Marko Myllynen
2016-07-21 6:57 ` Daniel Shahaf
2016-07-21 12:32 ` Marko Myllynen
2016-07-22 6:30 ` Daniel Shahaf
2016-07-22 8:17 ` Marko Myllynen
2016-07-21 16:12 ` Oliver Kiddle
2016-07-21 16:19 ` Marko Myllynen
2016-07-22 7:19 ` Daniel Shahaf
2016-08-31 21:15 ` Oliver Kiddle
2016-09-02 5:23 ` Daniel Shahaf
2016-09-02 15:02 ` Oliver Kiddle
2016-09-04 4:01 ` Daniel Shahaf
2016-09-07 6:39 ` Bart Schaefer
2016-09-09 22:09 ` Oliver Kiddle
2016-09-11 9:08 ` Daniel Shahaf
2016-09-14 23:19 ` Oliver Kiddle
2016-09-04 21:24 ` 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=16122.1468274870@hydra.kiddle.eu \
--to=okiddle@yahoo.co.uk \
--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).