[PATCH 06/11] vshCompleter: Pass partially parsed command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <mprivozn@xxxxxxxxxx>
---
 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@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux