virsh-completer: modify and fix bug in virshPoolTypeCompleter, now used for more commands

Signed-off-by: Adam Julis <ajulis@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Adam Julis authored and Michal Privoznik committed 2024-02-20 12:08:22 +01:00
1 parent c8ca9d0118
commit 7cb4a68500
3 files changed
+14 -4

No files matched your search

+7 -4
View File
@@ -93,13 +93,16 @@ virshPoolTypeCompleter(vshControl *ctl,
g_auto(GStrv) tmp = NULL;
const char *type_str = NULL;
virCheckFlags(0, NULL);
if (vshCommandOptStringQuiet(ctl, cmd, "type", &type_str) < 0)
return NULL;
virCheckFlags(VIRSH_POOL_TYPE_COMPLETER_COMMA, NULL);
tmp = virshEnumComplete(VIR_STORAGE_POOL_LAST,
virStoragePoolTypeToString);
if (!(flags & VIRSH_POOL_TYPE_COMPLETER_COMMA))
return g_steal_pointer(&tmp);
if (vshCommandOptStringQuiet(ctl, cmd, "type", &type_str) < 0)
return NULL;
return virshCommaStringListComplete(type_str, (const char **)tmp);
}
+4
View File
@@ -32,6 +32,10 @@ virshPoolEventNameCompleter(vshControl *ctl,
const vshCmd *cmd,
unsigned int flags);
enum {
VIRSH_POOL_TYPE_COMPLETER_COMMA = 1 << 0,
};
char **
virshPoolTypeCompleter(vshControl *ctl,
const vshCmd *cmd,
+3
View File
@@ -1089,6 +1089,7 @@ static const vshCmdOptDef opts_pool_list[] = {
{.name = "type",
.type = VSH_OT_STRING,
.completer = virshPoolTypeCompleter,
.completer_flags = VIRSH_POOL_TYPE_COMPLETER_COMMA,
.help = N_("only list pool of specified type(s) (if supported)")
},
{.name = "details",
@@ -1414,6 +1415,7 @@ static const vshCmdOptDef opts_find_storage_pool_sources_as[] = {
{.name = "type",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.completer = virshPoolTypeCompleter,
.help = N_("type of storage pool sources to find")
},
{.name = "host",
@@ -1501,6 +1503,7 @@ static const vshCmdOptDef opts_find_storage_pool_sources[] = {
{.name = "type",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.completer = virshPoolTypeCompleter,
.help = N_("type of storage pool sources to discover")
},
{.name = "srcSpec",