]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: Add virshCodesetNameCompleter
authorKristina Hanicova <khanicov@redhat.com>
Tue, 16 Feb 2021 20:15:43 +0000 (21:15 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 16 Feb 2021 20:26:54 +0000 (21:26 +0100)
This completer offers completion for --codeset argument of
send-key command.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
tools/virsh-completer-domain.c
tools/virsh-completer-domain.h
tools/virsh-domain.c

index e773af65528035668dd759ca157d60a379033d16..fc4d7b2e5211f54de6091dc78a97ad16a2875cca 100644 (file)
@@ -31,6 +31,7 @@
 #include "virxml.h"
 #include "virperf.h"
 #include "virbitmap.h"
+#include "virkeycode.h"
 
 char **
 virshDomainNameCompleter(vshControl *ctl,
@@ -778,3 +779,24 @@ virshDomainLifecycleActionCompleter(vshControl *ctl G_GNUC_UNUSED,
 
     return g_steal_pointer(&tmp);
 }
+
+
+char **
+virshCodesetNameCompleter(vshControl *ctl G_GNUC_UNUSED,
+                          const vshCmd *cmd G_GNUC_UNUSED,
+                          unsigned int flags)
+{
+    g_auto(GStrv) tmp = NULL;
+    size_t i = 0;
+
+    virCheckFlags(0, NULL);
+
+    tmp = g_new0(char *, VIR_KEYCODE_SET_LAST + 1);
+
+    for (i = 0; i < VIR_KEYCODE_SET_LAST; i++) {
+        const char *name = virKeycodeSetTypeToString(i);
+        tmp[i] = g_strdup(name);
+    }
+
+    return g_steal_pointer(&tmp);
+}
index 92c57bce758714253955904b9c313bcfd064cfa2..4c01b0ca1f919c9f01a07f929edfa3419d94032f 100644 (file)
@@ -110,3 +110,7 @@ char ** virshDomainLifecycleCompleter(vshControl *ctl,
 char ** virshDomainLifecycleActionCompleter(vshControl *ctl,
                                             const vshCmd *cmd,
                                             unsigned int flags);
+
+char ** virshCodesetNameCompleter(vshControl *ctl,
+                              const vshCmd *cmd,
+                              unsigned int flags);
index 1c58c26d93c86466a4f4843a62a9bf7b59db9964..d40995f44db2ecff0eefa96092599ef89e7c7b49 100644 (file)
@@ -8791,6 +8791,7 @@ static const vshCmdOptDef opts_send_key[] = {
     {.name = "codeset",
      .type = VSH_OT_STRING,
      .flags = VSH_OFLAG_REQ_OPT,
+     .completer = virshCodesetNameCompleter,
      .help = N_("the codeset of keycodes, default:linux")
     },
     {.name = "holdtime",