Mercurial > libervia-backend
diff sat_frontends/jp/cmd_pubsub.py @ 3521:62f490eff51c
jp (pubsub, blog): `rename` commands implementation
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 01 May 2021 18:39:34 +0200 |
parents | be6d91572633 |
children | 04283582966f |
line wrap: on
line diff
--- a/sat_frontends/jp/cmd_pubsub.py Sat May 01 18:38:58 2021 +0200 +++ b/sat_frontends/jp/cmd_pubsub.py Sat May 01 18:39:34 2021 +0200 @@ -960,6 +960,43 @@ self.host.quit() +class Rename(base.CommandBase): + + def __init__(self, host): + base.CommandBase.__init__( + self, + host, + "rename", + use_pubsub=True, + pubsub_flags={C.NODE, C.SINGLE_ITEM}, + help=_("rename a pubsub item"), + ) + + def add_parser_options(self): + self.parser.add_argument( + "new_id", + help=_("new item id to use") + ) + + async def start(self): + try: + await self.host.bridge.psItemRename( + self.args.service, + self.args.node, + self.args.item, + self.args.new_id, + self.profile, + ) + except Exception as e: + self.disp( + f"can't rename item: {e}", error=True + ) + self.host.quit(C.EXIT_BRIDGE_ERRBACK) + else: + self.disp("Item renamed") + self.host.quit(C.EXIT_OK) + + class Subscribe(base.CommandBase): def __init__(self, host): base.CommandBase.__init__( @@ -1982,6 +2019,7 @@ Get, Delete, Edit, + Rename, Subscribe, Unsubscribe, Subscriptions,