mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
virsh: Introduce virshPoolTypeCompleter
This completer can be used to complete pool types. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
This commit is contained in:
parent
37dbf05f28
commit
a9e8f7f63d
@ -21,6 +21,7 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include "virsh-completer-pool.h"
|
#include "virsh-completer-pool.h"
|
||||||
|
#include "conf/storage_conf.h"
|
||||||
#include "viralloc.h"
|
#include "viralloc.h"
|
||||||
#include "virsh-pool.h"
|
#include "virsh-pool.h"
|
||||||
#include "virsh.h"
|
#include "virsh.h"
|
||||||
@ -91,3 +92,29 @@ virshPoolEventNameCompleter(vshControl *ctl ATTRIBUTE_UNUSED,
|
|||||||
VIR_STEAL_PTR(ret, tmp);
|
VIR_STEAL_PTR(ret, tmp);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char **
|
||||||
|
virshPoolTypeCompleter(vshControl *ctl,
|
||||||
|
const vshCmd *cmd,
|
||||||
|
unsigned int flags)
|
||||||
|
{
|
||||||
|
VIR_AUTOSTRINGLIST tmp = NULL;
|
||||||
|
const char *type_str = NULL;
|
||||||
|
size_t i = 0;
|
||||||
|
|
||||||
|
virCheckFlags(0, NULL);
|
||||||
|
|
||||||
|
if (vshCommandOptStringQuiet(ctl, cmd, "type", &type_str) < 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (VIR_ALLOC_N(tmp, VIR_STORAGE_POOL_LAST + 1) < 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
for (i = 0; i < VIR_STORAGE_POOL_LAST; i++) {
|
||||||
|
if (VIR_STRDUP(tmp[i], virStoragePoolTypeToString(i)) < 0)
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return virshCommaStringListComplete(type_str, (const char **)tmp);
|
||||||
|
}
|
||||||
|
@ -29,3 +29,7 @@ char ** virshStoragePoolNameCompleter(vshControl *ctl,
|
|||||||
char ** virshPoolEventNameCompleter(vshControl *ctl,
|
char ** virshPoolEventNameCompleter(vshControl *ctl,
|
||||||
const vshCmd *cmd,
|
const vshCmd *cmd,
|
||||||
unsigned int flags);
|
unsigned int flags);
|
||||||
|
|
||||||
|
char ** virshPoolTypeCompleter(vshControl *ctl,
|
||||||
|
const vshCmd *cmd,
|
||||||
|
unsigned int flags);
|
||||||
|
@ -1095,6 +1095,7 @@ static const vshCmdOptDef opts_pool_list[] = {
|
|||||||
},
|
},
|
||||||
{.name = "type",
|
{.name = "type",
|
||||||
.type = VSH_OT_STRING,
|
.type = VSH_OT_STRING,
|
||||||
|
.completer = virshPoolTypeCompleter,
|
||||||
.help = N_("only list pool of specified type(s) (if supported)")
|
.help = N_("only list pool of specified type(s) (if supported)")
|
||||||
},
|
},
|
||||||
{.name = "details",
|
{.name = "details",
|
||||||
|
Loading…
Reference in New Issue
Block a user