From e03fb0b3ce41de208e4b52ee1224a080cfc5c6f5 Mon Sep 17 00:00:00 2001 From: mathieui Date: Sat, 9 May 2020 23:32:26 +0200 Subject: Fix completion and function names for /accept and /add --- poezio/core/commands.py | 4 ++-- poezio/core/completions.py | 8 ++++++++ poezio/core/core.py | 7 ++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/poezio/core/commands.py b/poezio/core/commands.py index f5594d5d..60bcc7b0 100644 --- a/poezio/core/commands.py +++ b/poezio/core/commands.py @@ -520,7 +520,7 @@ class CommandCore: @deny_anonymous @command_args_parser.quoted(0, 1) - def command_accept(self, args): + def accept(self, args): """ Accept a JID. Authorize it AND subscribe to it """ @@ -557,7 +557,7 @@ class CommandCore: @deny_anonymous @command_args_parser.quoted(1) - def command_add(self, args): + def add(self, args): """ Add the specified JID to the roster, and automatically accept the reverse subscription diff --git a/poezio/core/completions.py b/poezio/core/completions.py index ee3e95bf..544a7889 100644 --- a/poezio/core/completions.py +++ b/poezio/core/completions.py @@ -44,6 +44,14 @@ class CompletionCore: ' ', quotify=False) + def roster_barejids(self, the_input): + """Complete roster bare jids""" + jids = sorted( + str(contact.bare_jid) for contact in roster.contacts.values() + if contact.pending_in + ) + return Completion(the_input.new_completion, jids, 1, '', quotify=False) + def presence(self, the_input): """ Completion of /presence diff --git a/poezio/core/core.py b/poezio/core/core.py index 8f25d551..a0976c3c 100644 --- a/poezio/core/core.py +++ b/poezio/core/core.py @@ -1770,14 +1770,15 @@ class Core: completion=self.completion.bookmark) self.register_command( 'accept', - self.command.command_accept, + self.command.accept, usage='[jid]', desc='Allow the provided JID (or the selected contact ' 'in your roster), to see your presence.', - shortdesc='Allow a user your presence.',) + shortdesc='Allow a user your presence.', + completion=self.completion.roster_barejids) self.register_command( 'add', - self.command.command_add, + self.command.add, usage='', desc='Add the specified JID to your roster, ask them to' ' allow you to see his presence, and allow them to' -- cgit v1.2.3