changeset 3841:b337d7da72e5

li (blog): new `repeat` subcommand, to re-publish a blog post: rel 370
author Goffi <goffi@goffi.org>
date Thu, 14 Jul 2022 12:55:19 +0200
parents 5b192a5eb72d
children 943901372eba
files sat_frontends/jp/cmd_blog.py
diffstat 1 files changed, 34 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/sat_frontends/jp/cmd_blog.py	Wed Jul 13 12:15:04 2022 +0200
+++ b/sat_frontends/jp/cmd_blog.py	Thu Jul 14 12:55:19 2022 +0200
@@ -676,6 +676,39 @@
             self.host.quit(C.EXIT_OK)
 
 
+class Repeat(base.CommandBase):
+    def __init__(self, host):
+        super().__init__(
+            host,
+            "repeat",
+            use_pubsub=True,
+            pubsub_flags={C.SINGLE_ITEM},
+            help=_("repeat (re-publish) a blog item"),
+        )
+
+    def add_parser_options(self):
+        pass
+
+    async def start(self):
+        try:
+            repeat_id = await self.host.bridge.mbRepeat(
+                self.args.service,
+                self.args.node,
+                self.args.item,
+                "",
+                self.profile,
+            )
+        except Exception as e:
+            self.disp(f"can't repeat item: {e}", error=True)
+            self.host.quit(C.EXIT_BRIDGE_ERRBACK)
+        else:
+            if repeat_id:
+                self.disp(f"Item repeated at ID {str(repeat_id)!r}")
+            else:
+                self.disp("Item repeated")
+            self.host.quit(C.EXIT_OK)
+
+
 class Preview(base.CommandBase, common.BaseEdit):
     # TODO: need to be rewritten with template output
 
@@ -1039,7 +1072,7 @@
 
 
 class Blog(base.CommandBase):
-    subcommands = (Set, Get, Edit, Rename, Preview, Import)
+    subcommands = (Set, Get, Edit, Rename, Repeat, Preview, Import)
 
     def __init__(self, host):
         super(Blog, self).__init__(