1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-01-26 14:03:49 +03:00

virsh: Complete multiple options when any one option requires data

Before this patch:
    virsh # start --domain dom1 [TAB][TAB] <- offers filename completion
    virsh # start --domain [TAB][TAB] <- offers filename completion

After this patch:
    virsh # start --domain dom1 [TAB][TAB] <- offers command completion
    virsh # start --domain [TAB][TAB] <- calls domain completer if
    defined, otherwise falls back to filename completion

Signed-off-by: Nishith Shah <nishithshah.2211@gmail.com>
This commit is contained in:
Nishith Shah 2016-09-05 09:45:11 +00:00 committed by Michal Privoznik
parent 2550579669
commit 731ee28c5b

View File

@ -2731,6 +2731,7 @@ vshReadlineParse(const char *text, int state)
goto error; goto error;
} }
opts_seen = const_opts_seen;
opt_exists = true; opt_exists = true;
VIR_FREE(const_tkdata); VIR_FREE(const_tkdata);
if (opt->type != VSH_OT_BOOL) { if (opt->type != VSH_OT_BOOL) {
@ -2748,14 +2749,14 @@ vshReadlineParse(const char *text, int state)
goto error; goto error;
tkdata = const_tkdata; tkdata = const_tkdata;
virSkipSpaces((const char **)&tkdata);
} }
if (STREQ(tkdata, sanitized_text)) { if (STREQ(tkdata, sanitized_text)) {
/* auto-complete non-bool option arg */ /* auto-complete non-bool option arg */
data_complete = true; data_complete = true;
break; break;
} }
if (opt->type != VSH_OT_ARGV) non_bool_opt_exists = false;
opts_need_arg &= ~(1ULL << opt_index);
} else { } else {
tkdata = NULL; tkdata = NULL;
/* opt type is BOOL */ /* opt type is BOOL */