Mercurial > libervia-backend
diff sat_frontends/jp/cmd_roster.py @ 3414:ffe7a6d6018a
jp (roster): `delete` implementation
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 12 Nov 2020 14:53:16 +0100 |
parents | f30b238d9c45 |
children | be6d91572633 |
line wrap: on
line diff
--- a/sat_frontends/jp/cmd_roster.py Thu Nov 12 14:53:16 2020 +0100 +++ b/sat_frontends/jp/cmd_roster.py Thu Nov 12 14:53:16 2020 +0100 @@ -125,6 +125,33 @@ self.host.quit() +class Delete(base.CommandBase): + + def __init__(self, host): + super().__init__(host, 'delete', help=_('remove an entity from roster')) + + def add_parser_options(self): + self.parser.add_argument( + "-f", "--force", action="store_true", help=_("delete without confirmation") + ) + self.parser.add_argument( + "jid", help=_("jid of the roster entity")) + + async def start(self): + if not self.args.force: + message = _("Are you sure to delete {entity} fril your roster?").format( + entity=self.args.jid + ) + await self.host.confirmOrQuit(message, _("entity deletion cancelled")) + try: + await self.host.bridge.delContact( + self.args.jid, self.host.profile) + except Exception as e: + self.disp(f"error while deleting the entity: {e}", error=True) + self.host.quit(C.EXIT_BRIDGE_ERRBACK) + self.host.quit() + + class Stats(base.CommandBase): def __init__(self, host): @@ -293,7 +320,7 @@ class Roster(base.CommandBase): - subcommands = (Get, Set, Stats, Purge, Resync) + subcommands = (Get, Set, Delete, Stats, Purge, Resync) def __init__(self, host): super(Roster, self).__init__(