On 6/19/19 12:59 PM, Erik Skultety wrote:
On Tue, Jun 18, 2019 at 03:46:15PM +0200, Michal Privoznik wrote:
> There are more arguments than 'shutdown --mode' that accept a
> list of strings separated by commas. 'nodedev-list --cap' is one
> of them. To avoid duplicating code, let's separate interesting
> bits of virshDomainShutdownModeCompleter() into a function that
> can then be reused.
>
> Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
> ---
> tools/virsh-completer.c | 120 ++++++++++++++++++++++++++--------------
> 1 file changed, 77 insertions(+), 43 deletions(-)
>
> diff --git a/tools/virsh-completer.c b/tools/virsh-completer.c
> index 7d5cf8cb90..ef2f39320e 100644
> --- a/tools/virsh-completer.c
> +++ b/tools/virsh-completer.c
> @@ -69,6 +69,79 @@
> */
>
>
> +/**
> + * virshCommaStringListComplete:
> + * @input: user input so far
> + * @options: ALL options available for argument
> + *
> + * Some arguments to our commands accept the following form:
> + *
> + * virsh command --arg str1,str2,str3
> + *
> + * This does not play nicely with our completer funtions, because
> + * they have to return strings prepended with user's input. For
> + * instance:
> + *
> + * str1,str2,str3,strA
> + * str1,str2,str3,strB
> + * str1,str2,str3,strC
^This sounds rather sub-optimal. I wouldn't even insist on making the
suggestions contextual like it is now, IOW not suggesting options which have
already been specified and would rather return the same list of possible
options than a string with the user input prepended.
So IIUC, for 'shutdown --mode <TAB><TAB>' you want to see:
"acpi", "agent", "initctl", "signal",
"paravirt"
and for 'shutdown --mode acpi,agent,<TAB><TAB>' you want to see the
same
list again (optionally with already specified strings removed)? Yep,
that would be great but I don't think that is how readline works. At
least, I don't know how to achieve that. Do you perhaps have an idea?
Michal