1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-22 17:34:18 +03:00

virsh: Add virshCodesetNameCompleter

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>
This commit is contained in:
Kristina Hanicova 2021-02-16 21:15:43 +01:00 committed by Michal Privoznik
parent fa3d8a609a
commit 040a5bc307
3 changed files with 27 additions and 0 deletions

View 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);
}

View 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);

View 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",