Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: zsh virsh completion
- X-seq: zsh-workers 38832
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: zsh workers <zsh-workers@xxxxxxx>
- Subject: Re: zsh virsh completion
- Date: Tue, 12 Jul 2016 00:07:50 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1468274871; bh=kAok7UpBfAtBljXhLGmFmcILU+9srRUDdU063aI/MJQ=; h=In-reply-to:From:References:To:Subject:Date:From:Subject; b=Lex9oYMPmtBqlpDI+0oD0hXl3TY9+p82qIQ8cvMxCfs9SzLR1h2Pg3/vRilU7itoNtsREeuVuOY9EjA9SNNj5YV+fHlhsQ4V7n9inbq4MCZZBCBLrPGqZ83hSLyeaXmPanZahzCTvMLUaWzCzVO3v8crrvoyHY8LxYp7HJ33J0MkRpNAfTzalld9xQkdrJww5uw59cbNAWblnmiV94/0tldC3MpRpvGDmki8LCIbiK/AEC6IAHYUm1hfiuYWcklss9o3L3+x74ji7kvyI4Y1TxFA+5iPwaQ/CEeSvFgOtahXl1l9G36AQw0E9bzpWQtUnFd4G1oxHrZvk3k/FjYPLA==
- In-reply-to: <8eb6dce0-50d7-5ab2-503a-194c1de2e45d@redhat.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author