comparison libervia/cli/cmd_message.py @ 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 472a938a46e3
children
comparison
equal deleted inserted replaced
4315:8ee369e6eb99 4316:1795bfcc38e7
91 "--attach", 91 "--attach",
92 dest="attachments", 92 dest="attachments",
93 action="append", 93 action="append",
94 metavar="FILE_PATH", 94 metavar="FILE_PATH",
95 help=_("add a file as an attachment"), 95 help=_("add a file as an attachment"),
96 )
97
98 self.parser.add_argument(
99 "-k",
100 "--keyword",
101 dest="keywords",
102 action="append",
103 help=_("add keyword to message"),
104 )
105
106 self.parser.add_argument(
107 "-H",
108 "--header",
109 dest="headers",
110 action="append",
111 nargs=2,
112 metavar=("NAME", "VALUE"),
113 help=_("add header metadata"),
96 ) 114 )
97 115
98 addressing_group = self.parser.add_argument_group( 116 addressing_group = self.parser.add_argument_group(
99 "addressing commands", 117 "addressing commands",
100 description="Commands to add addressing metadata, and/or to send message to " 118 description="Commands to add addressing metadata, and/or to send message to "
146 key = "xhtml" if self.args.xhtml else "rich" 164 key = "xhtml" if self.args.xhtml else "rich"
147 if self.args.lang: 165 if self.args.lang:
148 key = f"{key}_{self.args.lang}" 166 key = f"{key}_{self.args.lang}"
149 extra[key] = clean_ustr("".join(stdin_lines)) 167 extra[key] = clean_ustr("".join(stdin_lines))
150 stdin_lines = [] 168 stdin_lines = []
169
170 if self.args.headers:
171 extra["headers"] = dict(self.args.headers)
151 172
152 addresses = {} 173 addresses = {}
153 for arg_name in RECIPIENTS_ARGS + [a.replace("-", "_") for a in REPLY_ARGS]: 174 for arg_name in RECIPIENTS_ARGS + [a.replace("-", "_") for a in REPLY_ARGS]:
154 values = getattr(self.args, arg_name) 175 values = getattr(self.args, arg_name)
155 if values: 176 if values:
164 if self.args.no_reply: 185 if self.args.no_reply:
165 addresses["noreply"] = True 186 addresses["noreply"] = True
166 187
167 if addresses: 188 if addresses:
168 extra["addresses"] = addresses 189 extra["addresses"] = addresses
190
191 if self.args.keywords:
192 extra["keywords"] = self.args.keywords
169 193
170 to_send = [] 194 to_send = []
171 195
172 error = False 196 error = False
173 197