jp (roster): delete implementation
This commit is contained in:
parent
df6428c14c
commit
92e424e685
2 changed files with 40 additions and 1 deletions
|
|
@ -72,6 +72,18 @@ Replace all groups of Pierre, to add him only to ``friends`` and ``housemates``:
|
|||
|
||||
$ 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
|
||||
=====
|
||||
|
||||
|
|
|
|||
|
|
@ -125,6 +125,33 @@ class Set(base.CommandBase):
|
|||
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 Resync(base.CommandBase):
|
|||
|
||||
|
||||
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__(
|
||||
|
|
|
|||
Loading…
Reference in a new issue