# HG changeset patch # User Goffi # Date 1605189196 -3600 # Node ID ffe7a6d6018a9afb52598e756fb3ce72c6f29638 # Parent f4d417593e773287e5a0f62fce5c4edf1e2b6291 jp (roster): `delete` implementation diff -r f4d417593e77 -r ffe7a6d6018a doc/jp/roster.rst --- a/doc/jp/roster.rst Thu Nov 12 14:53:16 2020 +0100 +++ b/doc/jp/roster.rst Thu Nov 12 14:53:16 2020 +0100 @@ -72,6 +72,18 @@ $ jp roster set --replace -g friends -g housemates pierre@example.net +delete +====== + +Remove an entity from roster. + +examples +-------- + +Remove John from your roster:: + + $ jp roster delete john@example.net + stats ===== diff -r f4d417593e77 -r ffe7a6d6018a sat_frontends/jp/cmd_roster.py --- 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__(