[PATCH 04/13] vsh: Add a VSH_OT_STRING argument for 'virsh echo'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The argument will be used for testing the command/option completer
function.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 tools/vsh.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/tools/vsh.c b/tools/vsh.c
index 8719875413..71c0778660 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -3246,6 +3246,10 @@ const vshCmdOptDef opts_echo[] = {
      .type = VSH_OT_ALIAS,
      .help = "string=hello"
     },
+    {.name = "prefix",
+     .type = VSH_OT_STRING,
+     .help = N_("prefix the message")
+    },
     {.name = "string",
      .type = VSH_OT_ARGV,
      .positional = true,
@@ -3269,6 +3273,7 @@ cmdEcho(vshControl *ctl, const vshCmd *cmd)
     bool xml = vshCommandOptBool(cmd, "xml");
     bool err = vshCommandOptBool(cmd, "err");
     bool split = vshCommandOptBool(cmd, "split");
+    const char *prefix;
     const vshCmdOpt *opt = NULL;
     g_autofree char *arg = NULL;
     g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
@@ -3277,6 +3282,11 @@ cmdEcho(vshControl *ctl, const vshCmd *cmd)
     VSH_EXCLUSIVE_OPTIONS_VAR(shell, split);
     VSH_EXCLUSIVE_OPTIONS_VAR(xml, split);

+    ignore_value(vshCommandOptString(ctl, cmd, "prefix", &prefix));
+
+    if (prefix)
+        virBufferAsprintf(&buf, "%s ", prefix);
+
     while ((opt = vshCommandOptArgv(ctl, cmd, opt))) {
         const char *curr = opt->data;

-- 
2.44.0
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux