The callback we're calling might need to make decisions on already passed arguments. For instance, a completer that is supposed to bring up list of domain's interfaces might want to see what domain user wants to work with.
Signed-off-by: Michal Privoznik <mpriv...@redhat.com> --- tools/vsh.c | 7 ++++++- tools/vsh.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/vsh.c b/tools/vsh.c index dd2f06ada..121669574 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -2859,9 +2859,14 @@ vshReadlineParse(const char *text, int state) } if (!complete_opts && complete_data) { - if (!completed_list && opt && opt->completer) + if (!completed_list && opt && opt->completer) { + vshCmd *partial = NULL; + vshCommandStringParse(autoCompleteOpaque, rl_line_buffer, &partial); completed_list = opt->completer(autoCompleteOpaque, + partial, opt->completer_flags); + vshCommandFree(partial); + } if (completed_list) { while ((completed_name = completed_list[completed_list_index])) { completed_list_index++; diff --git a/tools/vsh.h b/tools/vsh.h index 1ebd5c11a..c5a62e593 100644 --- a/tools/vsh.h +++ b/tools/vsh.h @@ -124,6 +124,7 @@ typedef struct _vshCmdOptDef vshCmdOptDef; typedef struct _vshControl vshControl; typedef char **(*vshCompleter)(vshControl *ctl, + const vshCmd *cmd, unsigned int flags); /* -- 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list