]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: completer: Introduce dummy completer for local files
authorPeter Krempa <pkrempa@redhat.com>
Wed, 15 Sep 2021 15:08:37 +0000 (17:08 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 17 Sep 2021 07:40:46 +0000 (09:40 +0200)
For now the completion does the correct thing of completing a local path
if NULL is returned.

Introduce 'virshCompletePathLocalExisting' and use it in the
'VIRSH_COMMON_OPT_FILE' macro.

This for now serves as an annotation for the function which want to read
a file on the host running virsh. In the future this can be used with a
more sophisticated implementation.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
tools/virsh-completer.c
tools/virsh-completer.h
tools/virsh.h

index 57e0c3905cde27a792ded292f530b356076bd156..100f2065985f240cbfe2a01b35d4e6dda6a9b639 100644 (file)
@@ -128,3 +128,20 @@ virshCommaStringListComplete(const char *input,
 
     return g_steal_pointer(&ret);
 }
+
+
+/**
+ * virshCompletePathLocalExisting:
+ *
+ * Complete a path to a existing file used as input. The file is used as input
+ * for virsh so only local files are considered.
+ *
+ * Note: For now this is a no-op. Readline does the correct thing.
+ */
+char **
+virshCompletePathLocalExisting(vshControl *ctl G_GNUC_UNUSED,
+                               const vshCmd *cmd G_GNUC_UNUSED,
+                               unsigned int completerflags G_GNUC_UNUSED)
+{
+    return NULL;
+}
index 1243a13a5e9557df5e84da7072f7bc260445c58e..9a77aa117f4955c47fd4ff687ca2d20542970361 100644 (file)
@@ -35,3 +35,8 @@
 char **
 virshCommaStringListComplete(const char *input,
                              const char **options);
+
+char **
+virshCompletePathLocalExisting(vshControl *ctl,
+                               const vshCmd *cmd,
+                               unsigned int completerflags);
index 8e1b8ced90197a61a1715e0469d2db83e5205716..cacd54db5772f6f370e4b9e5a146a4214ab2208c 100644 (file)
     {.name = "file", \
      .type = VSH_OT_DATA, \
      .flags = VSH_OFLAG_REQ, \
+     .completer = virshCompletePathLocalExisting, \
      .help = _helpstr \
     }