From b533b3e56cb92267d6ce660ddc6a557e0563a673 Mon Sep 17 00:00:00 2001 From: Goffi Date: Thu, 14 Jul 2022 12:55:19 +0200 Subject: [PATCH] li (blog): new `repeat` subcommand, to re-publish a blog post: rel 370 --- sat_frontends/jp/cmd_blog.py | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/sat_frontends/jp/cmd_blog.py b/sat_frontends/jp/cmd_blog.py index 449a7e83..b49bd19e 100644 --- a/sat_frontends/jp/cmd_blog.py +++ b/sat_frontends/jp/cmd_blog.py @@ -676,6 +676,39 @@ class Rename(base.CommandBase): 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 Import(base.CommandBase): 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__(