On 2/20/24 10:31, Adam Julis wrote:
Signed-off-by: Adam Julis <ajulis(a)redhat.com>
---
v2:
- instead new completer is used already existing virshPoolTypeCompleter
- added flag VIRSH_POOL_TYPE_COMPLETER_COMMA for the completer
- fixed bug in pool-list --type command
v1:
https://lists.libvirt.org/archives/list/devel@lists.libvirt.org/message/K...
tools/virsh-completer-domain.h | 4 ++++
tools/virsh-completer-pool.c | 14 +++++++++-----
tools/virsh-pool.c | 3 +++
3 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/tools/virsh-completer-pool.c b/tools/virsh-completer-pool.c
index 0600394411..abad0fca1b 100644
--- a/tools/virsh-completer-pool.c
+++ b/tools/virsh-completer-pool.c
@@ -93,13 +93,17 @@ 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);
- return virshCommaStringListComplete(type_str, (const char **)tmp);
+ if (flags & VIRSH_POOL_TYPE_COMPLETER_COMMA){
+ if (vshCommandOptStringQuiet(ctl, cmd, "type", &type_str) < 0)
+ return NULL;
+
+ return virshCommaStringListComplete(type_str, (const char **)tmp);
+ }
+
+ return g_steal_pointer(&tmp);
}
Consider this squashed in
diff --git i/tools/virsh-completer-pool.c w/tools/virsh-completer-pool.c
index abad0fca1b..f3f10de943 100644
--- i/tools/virsh-completer-pool.c
+++ w/tools/virsh-completer-pool.c
@@ -98,7 +98,7 @@ virshPoolTypeCompleter(vshControl *ctl,
tmp = virshEnumComplete(VIR_STORAGE_POOL_LAST,
virStoragePoolTypeToString);
- if (flags & VIRSH_POOL_TYPE_COMPLETER_COMMA){
+ if (flags & VIRSH_POOL_TYPE_COMPLETER_COMMA) {
if (vshCommandOptStringQuiet(ctl, cmd, "type", &type_str) < 0)
return NULL;