[PATCH v2 07/12] 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 | 9 ++++++++-
 tools/vsh.h | 1 +
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/tools/vsh.c b/tools/vsh.c
index 3ed6bb916..9cf85b180 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -2863,9 +2863,16 @@ 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);
+                if (partial)
+                    partial->skipChecks = true;
                 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 51f8ef213..ae40fb4e8 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