[libvirt] [PATCH 04/18] vshCommandStringParse: Allow retrieving partial result

Martin Kletzander mkletzan at redhat.com
Thu Jan 11 10:48:36 UTC 2018


On Tue, Jan 02, 2018 at 06:11:57PM +0100, Michal Privoznik wrote:
>In the future, this function is going to be called from
>vshReadlineParse() to provide parsed input for completer
>callbacks. The idea is to allow the callbacks to provide more
>specific data. For instance, for the following input:
>
>  virsh # domifaddr --domain fedora --interface <TAB><TAB>
>
>the --interface completer callback is going to be called. Now, it
>is more user friendly if the completer offers only those
>interfaces found in 'fedora' domain. But in order to do that it
>needs to be able to retrieve partially parsed result.
>
>Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
>---
> tools/virsh.c      |   4 +-
> tools/virt-admin.c |   4 +-
> tools/vsh.c        | 111 +++++++++++++++++++++++++++++++++++++----------------
> tools/vsh.h        |   2 +-
> 4 files changed, 82 insertions(+), 39 deletions(-)
>
>diff --git a/tools/vsh.c b/tools/vsh.c
>index 2366b7b71..34eb592ef 100644
>--- a/tools/vsh.c
>+++ b/tools/vsh.c
>@@ -1519,11 +1544,12 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser)
>                     last->next = arg;
>                 last = arg;
>
>-                vshDebug(ctl, VSH_ERR_INFO, "%s: %s(%s): %s\n",
>-                         cmd->name,
>-                         opt->name,
>-                         opt->type != VSH_OT_BOOL ? _("optdata") : _("bool"),
>-                         opt->type != VSH_OT_BOOL ? arg->data : _("(none)"));
>+                if (ctl)

Don't you mean (!partial) here?  This change looks weird otherwise.

After reading the following patches I see that you call this with ctl == NULL
(from readline).  That makes sense, but there are few more places where ctl is
used even when partial != NULL and that needs to be handled correctly.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20180111/75085393/attachment-0001.sig>


More information about the libvir-list mailing list