changeset 4316:1795bfcc38e7

cli (message/send): add arguments to send keywords and headers: rel 451
author Goffi <goffi@goffi.org>
date Sat, 28 Sep 2024 15:57:31 +0200
parents 8ee369e6eb99
children 055930cc81f9
files libervia/cli/cmd_message.py
diffstat 1 files changed, 24 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libervia/cli/cmd_message.py	Sat Sep 28 15:57:03 2024 +0200
+++ b/libervia/cli/cmd_message.py	Sat Sep 28 15:57:31 2024 +0200
@@ -95,6 +95,24 @@
             help=_("add a file as an attachment"),
         )
 
+        self.parser.add_argument(
+            "-k",
+            "--keyword",
+            dest="keywords",
+            action="append",
+            help=_("add keyword to message"),
+        )
+
+        self.parser.add_argument(
+            "-H",
+            "--header",
+            dest="headers",
+            action="append",
+            nargs=2,
+            metavar=("NAME", "VALUE"),
+            help=_("add header metadata"),
+        )
+
         addressing_group = self.parser.add_argument_group(
             "addressing commands",
             description="Commands to add addressing metadata, and/or to send message to "
@@ -149,6 +167,9 @@
             extra[key] = clean_ustr("".join(stdin_lines))
             stdin_lines = []
 
+        if self.args.headers:
+            extra["headers"] = dict(self.args.headers)
+
         addresses = {}
         for arg_name in RECIPIENTS_ARGS + [a.replace("-", "_") for a in REPLY_ARGS]:
             values = getattr(self.args, arg_name)
@@ -167,6 +188,9 @@
         if addresses:
             extra["addresses"] = addresses
 
+        if self.args.keywords:
+            extra["keywords"] = self.args.keywords
+
         to_send = []
 
         error = False