summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2020-12-12 23:54:17 +0100
committermathieui <mathieui@mathieui.net>2021-01-28 19:03:54 +0100
commitf808f0cff98ae5ff7f093c1b87b630184138464b (patch)
tree66254df10114edf534eee05d21113e57e0dd0218
parent08f48b0c8be7535754ba9494d13276f69485bd44 (diff)
downloadpoezio-f808f0cff98ae5ff7f093c1b87b630184138464b.tar.gz
poezio-f808f0cff98ae5ff7f093c1b87b630184138464b.tar.bz2
poezio-f808f0cff98ae5ff7f093c1b87b630184138464b.tar.xz
poezio-f808f0cff98ae5ff7f093c1b87b630184138464b.zip
core: move initial commands in a separate files
(improve core.py SNR)
-rw-r--r--poezio/core/command_defs.py442
-rw-r--r--poezio/core/commands.py8
-rw-r--r--poezio/core/core.py324
-rw-r--r--poezio/core/structs.py6
4 files changed, 459 insertions, 321 deletions
diff --git a/poezio/core/command_defs.py b/poezio/core/command_defs.py
new file mode 100644
index 00000000..643e2289
--- /dev/null
+++ b/poezio/core/command_defs.py
@@ -0,0 +1,442 @@
+from poezio.core.commands import CommandCore
+from poezio.core.completions import CompletionCore
+from poezio.plugin_manager import PluginManager
+
+from typing import TypedDict, Callable, List
+
+CommandDict = TypedDict(
+ "CommandDict",
+ {
+ "name": str,
+ "func": Callable,
+ "shortdesc": str,
+ "desc": str,
+ "completion": Callable,
+ },
+ total=False,
+)
+
+
+def get_commands(commands: CommandCore, completions: CompletionCore, plugin_manager: PluginManager) -> List[CommandDict]:
+ """
+ Get the set of default poezio commands.
+ """
+ return [
+ {
+ "name": "help",
+ "func": commands.help,
+ "usage": "[command]",
+ "shortdesc": "\\_o< KOIN KOIN KOIN",
+ "completion": completions.help,
+ },
+ {
+ "name": "join",
+ "func": commands.join,
+ "usage": "[room_name][@server][/nick] [password]",
+ "desc": (
+ "Join the specified room. You can specify a nickname "
+ "after a slash (/). If no nickname is specified, you will"
+ " use the default_nick in the configuration file. You can"
+ " omit the room name: you will then join the room you're"
+ " looking at (useful if you were kicked). You can also "
+ "provide a room_name without specifying a server, the "
+ "server of the room you're currently in will be used. You"
+ " can also provide a password to join the room.\nExamples"
+ ":\n/join room@server.tld\n/join room@server.tld/John\n"
+ "/join room2\n/join /me_again\n/join\n/join room@server"
+ ".tld/my_nick password\n/join / password"
+ ),
+ "shortdesc": "Join a room",
+ "completion": completions.join,
+ },
+ {
+ "name": "exit",
+ "func": commands.quit,
+ "desc": "Just disconnect from the server and exit poezio.",
+ "shortdesc": "Exit poezio.",
+ },
+ {
+ "name": "quit",
+ "func": commands.quit,
+ "desc": "Just disconnect from the server and exit poezio.",
+ "shortdesc": "Exit poezio.",
+ },
+ {
+ "name": "next",
+ "func": commands.rotate_rooms_right,
+ "shortdesc": "Go to the next room.",
+ },
+ {
+ "name": "prev",
+ "func": commands.rotate_rooms_left,
+ "shortdesc": "Go to the previous room.",
+ },
+ {
+ "name": "win",
+ "func": commands.win,
+ "usage": "<number or name>",
+ "shortdesc": "Go to the specified room",
+ "completion": completions.win,
+ },
+ {
+ "name": "w",
+ "func": commands.win,
+ "usage": "<number or name>",
+ "shortdesc": "Go to the specified room",
+ "completion": completions.win,
+ },
+ {
+ "name": "wup",
+ "func": commands.wup,
+ "usage": "<prefix>",
+ "shortdesc": "Go to the tab whose name uniquely starts with prefix",
+ "completion": completions.win,
+ },
+ {
+ "name": "move_tab",
+ "func": commands.move_tab,
+ "usage": "<source> <destination>",
+ "desc": (
+ "Insert the <source> tab at the position of "
+ "<destination>. This will make the following tabs shift in"
+ " some cases (refer to the documentation). A tab can be "
+ "designated by its number or by the beginning of its "
+ 'address. You can use "." as a shortcut for the current '
+ "tab."
+ ),
+ "shortdesc": "Move a tab.",
+ "completion": completions.move_tab,
+ },
+ {
+ "name": "destroy_room",
+ "func": commands.destroy_room,
+ "usage": "[room JID]",
+ "desc": (
+ "Try to destroy the room [room JID], or the current"
+ " tab if it is a multi-user chat and [room JID] is "
+ "not given."
+ ),
+ "shortdesc": "Destroy a room.",
+ "completion": None,
+ },
+ {
+ "name": "status",
+ "func": commands.status,
+ "usage": "<availability> [status message]",
+ "desc": (
+ "Sets your availability and (optionally) your status "
+ 'message. The <availability> argument is one of "available'
+ ', chat, away, afk, dnd, busy, xa" and the optional '
+ "[status message] argument will be your status message."
+ ),
+ "shortdesc": "Change your availability.",
+ "completion": completions.status,
+ },
+ {
+ "name": "show",
+ "func": commands.status,
+ "usage": "<availability> [status message]",
+ "desc": (
+ "Sets your availability and (optionally) your status "
+ 'message. The <availability> argument is one of "available'
+ ', chat, away, afk, dnd, busy, xa" and the optional '
+ "[status message] argument will be your status message."
+ ),
+ "shortdesc": "Change your availability.",
+ "completion": completions.status,
+ },
+ {
+ "name": "bookmark_local",
+ "func": commands.bookmark_local,
+ "usage": "[roomname][/nick] [password]",
+ "desc": (
+ "Bookmark Local: Bookmark locally the specified room "
+ "(you will then auto-join it on each poezio start). This"
+ " commands uses almost the same syntaxe as /join. Type "
+ "/help join for syntax examples. Note that when typing "
+ '"/bookmark" on its own, the room will be bookmarked '
+ "with the nickname you're currently using in this room "
+ "(instead of default_nick)"
+ ),
+ "shortdesc": "Bookmark a room locally.",
+ "completion": completions.bookmark_local,
+ },
+ {
+ "name": "bookmark",
+ "func": commands.bookmark,
+ "usage": "[roomname][/nick] [autojoin] [password]",
+ "desc": (
+ "Bookmark: Bookmark online the specified room (you "
+ "will then auto-join it on each poezio start if autojoin"
+ " is specified and is 'true'). This commands uses almost"
+ " the same syntax as /join. Type /help join for syntax "
+ 'examples. Note that when typing "/bookmark" alone, the'
+ " room will be bookmarked with the nickname you're "
+ "currently using in this room (instead of default_nick)."
+ ),
+ "shortdesc": "Bookmark a room online.",
+ "completion": completions.bookmark,
+ },
+ {
+ "name": "accept",
+ "func": commands.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.",
+ "completion": completions.roster_barejids,
+ },
+ {
+ "name": "add",
+ "func": commands.add,
+ "usage": "<jid>",
+ "desc": (
+ "Add the specified JID to your roster, ask them to"
+ " allow you to see his presence, and allow them to"
+ " see your presence."
+ ),
+ "shortdesc": "Add a user to your roster.",
+ },
+ {
+ "name": "deny",
+ "func": commands.deny,
+ "usage": "[jid]",
+ "desc": (
+ "Deny your presence to the provided JID (or the "
+ "selected contact in your roster), who is asking"
+ "you to be in their roster."
+ ),
+ "shortdesc": "Deny a user your presence.",
+ "completion": completions.roster_barejids,
+ },
+ {
+ "name": "remove",
+ "func": commands.remove,
+ "usage": "[jid]",
+ "desc": (
+ "Remove the specified JID from your roster. This "
+ "will unsubscribe you from its presence, cancel "
+ "its subscription to yours, and remove the item "
+ "from your roster."
+ ),
+ "shortdesc": "Remove a user from your roster.",
+ "completion": completions.remove,
+ },
+ {
+ "name": "reconnect",
+ "func": commands.command_reconnect,
+ "usage": "[reconnect]",
+ "desc": (
+ "Disconnect from the remote server if you are "
+ "currently connected and then connect to it again."
+ ),
+ "shortdesc": "Disconnect and reconnect to the server.",
+ },
+ {
+ "name": "set",
+ "func": commands.set,
+ "usage": "[plugin|][section] <option> [value]",
+ "desc": (
+ "Set the value of an option in your configuration file."
+ " You can, for example, change your default nickname by "
+ "doing `/set default_nick toto` or your resource with `/set"
+ " resource blabla`. You can also set options in specific "
+ "sections with `/set bindings M-i ^i` or in specific plugin"
+ " with `/set mpd_client| host 127.0.0.1`. `toggle` can be "
+ "used as a special value to toggle a boolean option."
+ ),
+ "shortdesc": "Set the value of an option",
+ "completion": completions.set,
+ },
+ {
+ "name": "set_default",
+ "func": commands.set_default,
+ "usage": "[section] <option>",
+ "desc": (
+ "Set the default value of an option. For example, "
+ "`/set_default resource` will reset the resource "
+ "option. You can also reset options in specific "
+ "sections by doing `/set_default section option`."
+ ),
+ "shortdesc": "Set the default value of an option",
+ "completion": completions.set_default,
+ },
+ {
+ "name": "toggle",
+ "func": commands.toggle,
+ "usage": "<option>",
+ "desc": "Shortcut for /set <option> toggle",
+ "shortdesc": "Toggle an option",
+ "completion": completions.toggle,
+ },
+ {
+ "name": "theme",
+ "func": commands.theme,
+ "usage": "[theme name]",
+ "desc": (
+ "Reload the theme defined in the config file. If theme"
+ "_name is provided, set that theme before reloading it."
+ ),
+ "shortdesc": "Load a theme",
+ "completion": completions.theme,
+ },
+ {
+ "name": "list",
+ "func": commands.list,
+ "usage": "[server]",
+ "desc": "Get the list of public rooms" " on the specified server.",
+ "shortdesc": "List the rooms.",
+ "completion": completions.list,
+ },
+ {
+ "name": "message",
+ "func": commands.message,
+ "usage": "<jid> [optional message]",
+ "desc": (
+ "Open a conversation with the specified JID (even if it"
+ " is not in our roster), and send a message to it, if the "
+ "message is specified."
+ ),
+ "shortdesc": "Send a message",
+ "completion": completions.message,
+ },
+ {
+ "name": "version",
+ "func": commands.version,
+ "usage": "<jid>",
+ "desc": (
+ "Get the software version of the given JID (usually its"
+ " XMPP client and Operating System)."
+ ),
+ "shortdesc": "Get the software version of a JID.",
+ "completion": completions.version,
+ },
+ {
+ "name": "server_cycle",
+ "func": commands.server_cycle,
+ "usage": "[domain] [message]",
+ "desc": "Disconnect and reconnect in all the rooms in domain.",
+ "shortdesc": "Cycle a range of rooms",
+ "completion": completions.server_cycle,
+ },
+ {
+ "name": "bind",
+ "func": commands.bind,
+ "usage": "<key> <equ>",
+ "desc": (
+ "Bind a key to another key or to a “command”. For "
+ 'example "/bind ^H KEY_UP" makes Control + h do the'
+ " same same as the Up key."
+ ),
+ "completion": completions.bind,
+ "shortdesc": "Bind a key to another key.",
+ },
+ {
+ "name": "load",
+ "func": commands.load,
+ "usage": "<plugin> [<otherplugin> …]",
+ "shortdesc": "Load the specified plugin(s)",
+ "completion": plugin_manager.completion_load,
+ },
+ {
+ "name": "unload",
+ "func": commands.unload,
+ "usage": "<plugin> [<otherplugin> …]",
+ "shortdesc": "Unload the specified plugin(s)",
+ "completion": plugin_manager.completion_unload,
+ },
+ {
+ "name": "plugins",
+ "func": commands.plugins,
+ "shortdesc": "Show the plugins in use.",
+ },
+ {
+ "name": "presence",
+ "func": commands.presence,
+ "usage": "<JID> [type] [status]",
+ "desc": "Send a directed presence to <JID> and using"
+ " [type] and [status] if provided.",
+ "shortdesc": "Send a directed presence.",
+ "completion": completions.presence,
+ },
+ {
+ "name": "rawxml",
+ "func": commands.rawxml,
+ "usage": "<xml>",
+ "shortdesc": "Send a custom xml stanza.",
+ },
+ {
+ "name": "invite",
+ "func": commands.invite,
+ "usage": "<jid> <room> [reason]",
+ "desc": "Invite jid in room with reason.",
+ "shortdesc": "Invite someone in a room.",
+ "completion": completions.invite,
+ },
+ {
+ "name": "impromptu",
+ "func": commands.impromptu,
+ "usage": "<jid> [jid ...]",
+ "desc": "Invite specified JIDs into a newly created room.",
+ "shortdesc": "Invite specified JIDs into newly created room.",
+ "completion": completions.impromptu,
+ },
+ {
+ "name": "invitations",
+ "func": commands.invitations,
+ "shortdesc": "Show the pending invitations.",
+ },
+ {
+ "name": "bookmarks",
+ "func": commands.bookmarks,
+ "shortdesc": "Show the current bookmarks.",
+ },
+ {
+ "name": "remove_bookmark",
+ "func": commands.remove_bookmark,
+ "usage": "[jid]",
+ "desc": "Remove the specified bookmark, or the "
+ "bookmark on the current tab, if any.",
+ "shortdesc": "Remove a bookmark",
+ "completion": completions.remove_bookmark,
+ },
+ {
+ "name": "xml_tab",
+ "func": commands.xml_tab,
+ "shortdesc": "Open an XML tab.",
+ },
+ {
+ "name": "runkey",
+ "func": commands.runkey,
+ "usage": "<key>",
+ "shortdesc": "Execute the action defined for <key>.",
+ "completion": completions.runkey,
+ },
+ {
+ "name": "self",
+ "func": commands.self_,
+ "shortdesc": "Remind you of who you are.",
+ },
+ {
+ "name": "last_activity",
+ "func": commands.last_activity,
+ "usage": "<jid>",
+ "desc": "Informs you of the last activity of a JID.",
+ "shortdesc": "Get the activity of someone.",
+ "completion": completions.last_activity,
+ },
+ {
+ "name": "ad-hoc",
+ "func": commands.adhoc,
+ "usage": "<jid>",
+ "shortdesc": "List available ad-hoc commands on the given jid",
+ },
+ {
+ "name": "reload",
+ "func": commands.reload,
+ "shortdesc": "Reload the config. You can achieve the same by "
+ "sending SIGUSR1 to poezio.",
+ },
+ ]
diff --git a/poezio/core/commands.py b/poezio/core/commands.py
index 351d816d..03ca0a61 100644
--- a/poezio/core/commands.py
+++ b/poezio/core/commands.py
@@ -37,6 +37,14 @@ class CommandCore:
def __init__(self, core):
self.core = core
+ @command_args_parser.ignored
+ def rotate_rooms_left(self, args=None):
+ self.core.rotate_rooms_left()
+
+ @command_args_parser.ignored
+ def rotate_rooms_right(self, args=None):
+ self.core.rotate_rooms_right()
+
@command_args_parser.quoted(0, 1)
def help(self, args):
"""
diff --git a/poezio/core/core.py b/poezio/core/core.py
index c79750de..fa76e1d2 100644
--- a/poezio/core/core.py
+++ b/poezio/core/core.py
@@ -63,6 +63,7 @@ from poezio import keyboard, xdg
from poezio.core.completions import CompletionCore
from poezio.core.tabs import Tabs
from poezio.core.commands import CommandCore
+from poezio.core.command_defs import get_commands
from poezio.core.handlers import HandlerCore
from poezio.core.structs import (
Command,
@@ -1053,13 +1054,13 @@ class Core:
### Move actions (e.g. go to next room) ###
- def rotate_rooms_right(self, args=None) -> None:
+ def rotate_rooms_right(self) -> None:
"""
rotate the rooms list to the right
"""
self.tabs.next()
- def rotate_rooms_left(self, args=None) -> None:
+ def rotate_rooms_left(self) -> None:
"""
rotate the rooms list to the right
"""
@@ -1675,323 +1676,8 @@ class Core:
"""
Register the commands when poezio starts
"""
- self.register_command(
- 'help',
- self.command.help,
- usage='[command]',
- shortdesc='\\_o< KOIN KOIN KOIN',
- completion=self.completion.help)
- self.register_command(
- 'join',
- self.command.join,
- usage="[room_name][@server][/nick] [password]",
- desc="Join the specified room. You can specify a nickname "
- "after a slash (/). If no nickname is specified, you will"
- " use the default_nick in the configuration file. You can"
- " omit the room name: you will then join the room you\'re"
- " looking at (useful if you were kicked). You can also "
- "provide a room_name without specifying a server, the "
- "server of the room you're currently in will be used. You"
- " can also provide a password to join the room.\nExamples"
- ":\n/join room@server.tld\n/join room@server.tld/John\n"
- "/join room2\n/join /me_again\n/join\n/join room@server"
- ".tld/my_nick password\n/join / password",
- shortdesc='Join a room',
- completion=self.completion.join)
- self.register_command(
- 'exit',
- self.command.quit,
- desc='Just disconnect from the server and exit poezio.',
- shortdesc='Exit poezio.')
- self.register_command(
- 'quit',
- self.command.quit,
- desc='Just disconnect from the server and exit poezio.',
- shortdesc='Exit poezio.')
- self.register_command(
- 'next', self.rotate_rooms_right, shortdesc='Go to the next room.')
- self.register_command(
- 'prev',
- self.rotate_rooms_left,
- shortdesc='Go to the previous room.')
- self.register_command(
- 'win',
- self.command.win,
- usage='<number or name>',
- shortdesc='Go to the specified room',
- completion=self.completion.win)
- self.register_command(
- 'wup',
- self.command.wup,
- usage='<prefix>',
- shortdesc='Go to the tab whose name uniquely starts with prefix',
- completion=self.completion.win)
- self.commands['w'] = self.commands['win']
- self.register_command(
- 'move_tab',
- self.command.move_tab,
- usage='<source> <destination>',
- desc="Insert the <source> tab at the position of "
- "<destination>. This will make the following tabs shift in"
- " some cases (refer to the documentation). A tab can be "
- "designated by its number or by the beginning of its "
- "address. You can use \".\" as a shortcut for the current "
- "tab.",
- shortdesc='Move a tab.',
- completion=self.completion.move_tab)
- self.register_command(
- 'destroy_room',
- self.command.destroy_room,
- usage='[room JID]',
- desc='Try to destroy the room [room JID], or the current'
- ' tab if it is a multi-user chat and [room JID] is '
- 'not given.',
- shortdesc='Destroy a room.',
- completion=None)
- self.register_command(
- 'show',
- self.command.status,
- usage='<availability> [status message]',
- desc="Sets your availability and (optionally) your status "
- "message. The <availability> argument is one of \"available"
- ", chat, away, afk, dnd, busy, xa\" and the optional "
- "[status message] argument will be your status message.",
- shortdesc='Change your availability.',
- completion=self.completion.status)
- self.commands['status'] = self.commands['show']
- self.register_command(
- 'bookmark_local',
- self.command.bookmark_local,
- usage="[roomname][/nick] [password]",
- desc="Bookmark Local: Bookmark locally the specified room "
- "(you will then auto-join it on each poezio start). This"
- " commands uses almost the same syntaxe as /join. Type "
- "/help join for syntax examples. Note that when typing "
- "\"/bookmark\" on its own, the room will be bookmarked "
- "with the nickname you\'re currently using in this room "
- "(instead of default_nick)",
- shortdesc='Bookmark a room locally.',
- completion=self.completion.bookmark_local)
- self.register_command(
- 'bookmark',
- self.command.bookmark,
- usage="[roomname][/nick] [autojoin] [password]",
- desc="Bookmark: Bookmark online the specified room (you "
- "will then auto-join it on each poezio start if autojoin"
- " is specified and is 'true'). This commands uses almost"
- " the same syntax as /join. Type /help join for syntax "
- "examples. Note that when typing \"/bookmark\" alone, the"
- " room will be bookmarked with the nickname you\'re "
- "currently using in this room (instead of default_nick).",
- shortdesc="Bookmark a room online.",
- completion=self.completion.bookmark)
- self.register_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.',
- completion=self.completion.roster_barejids)
- self.register_command(
- 'add',
- self.command.add,
- usage='<jid>',
- desc='Add the specified JID to your roster, ask them to'
- ' allow you to see his presence, and allow them to'
- ' see your presence.',
- shortdesc='Add a user to your roster.')
- self.register_command(
- 'deny',
- self.command.deny,
- usage='[jid]',
- desc='Deny your presence to the provided JID (or the '
- 'selected contact in your roster), who is asking'
- 'you to be in their roster.',
- shortdesc='Deny a user your presence.',
- completion=self.completion.roster_barejids)
- self.register_command(
- 'remove',
- self.command.remove,
- usage='[jid]',
- desc='Remove the specified JID from your roster. This '
- 'will unsubscribe you from its presence, cancel '
- 'its subscription to yours, and remove the item '
- 'from your roster.',
- shortdesc='Remove a user from your roster.',
- completion=self.completion.remove)
- self.register_command(
- 'reconnect',
- self.command.command_reconnect,
- usage="[reconnect]",
- desc='Disconnect from the remote server if you are '
- 'currently connected and then connect to it again.',
- shortdesc='Disconnect and reconnect to the server.')
- self.register_command(
- 'set',
- self.command.set,
- usage="[plugin|][section] <option> [value]",
- desc="Set the value of an option in your configuration file."
- " You can, for example, change your default nickname by "
- "doing `/set default_nick toto` or your resource with `/set"
- " resource blabla`. You can also set options in specific "
- "sections with `/set bindings M-i ^i` or in specific plugin"
- " with `/set mpd_client| host 127.0.0.1`. `toggle` can be "
- "used as a special value to toggle a boolean option.",
- shortdesc="Set the value of an option",
- completion=self.completion.set)
- self.register_command(
- 'set_default',
- self.command.set_default,
- usage="[section] <option>",
- desc="Set the default value of an option. For example, "
- "`/set_default resource` will reset the resource "
- "option. You can also reset options in specific "
- "sections by doing `/set_default section option`.",
- shortdesc="Set the default value of an option",
- completion=self.completion.set_default)
- self.register_command(
- 'toggle',
- self.command.toggle,
- usage='<option>',
- desc='Shortcut for /set <option> toggle',
- shortdesc='Toggle an option',
- completion=self.completion.toggle)
- self.register_command(
- 'theme',
- self.command.theme,
- usage='[theme name]',
- desc="Reload the theme defined in the config file. If theme"
- "_name is provided, set that theme before reloading it.",
- shortdesc='Load a theme',
- completion=self.completion.theme)
- self.register_command(
- 'list',
- self.command.list,
- usage='[server]',
- desc="Get the list of public rooms"
- " on the specified server.",
- shortdesc='List the rooms.',
- completion=self.completion.list)
- self.register_command(
- 'message',
- self.command.message,
- usage='<jid> [optional message]',
- desc="Open a conversation with the specified JID (even if it"
- " is not in our roster), and send a message to it, if the "
- "message is specified.",
- shortdesc='Send a message',
- completion=self.completion.message)
- self.register_command(
- 'version',
- self.command.version,
- usage='<jid>',
- desc="Get the software version of the given JID (usually its"
- " XMPP client and Operating System).",
- shortdesc='Get the software version of a JID.',
- completion=self.completion.version)
- self.register_command(
- 'server_cycle',
- self.command.server_cycle,
- usage='[domain] [message]',
- desc='Disconnect and reconnect in all the rooms in domain.',
- shortdesc='Cycle a range of rooms',
- completion=self.completion.server_cycle)
- self.register_command(
- 'bind',
- self.command.bind,
- usage='<key> <equ>',
- desc="Bind a key to another key or to a “command”. For "
- "example \"/bind ^H KEY_UP\" makes Control + h do the"
- " same same as the Up key.",
- completion=self.completion.bind,
- shortdesc='Bind a key to another key.')
- self.register_command(
- 'load',
- self.command.load,
- usage='<plugin> [<otherplugin> …]',
- shortdesc='Load the specified plugin(s)',
- completion=self.plugin_manager.completion_load)
- self.register_command(
- 'unload',
- self.command.unload,
- usage='<plugin> [<otherplugin> …]',
- shortdesc='Unload the specified plugin(s)',
- completion=self.plugin_manager.completion_unload)
- self.register_command(
- 'plugins',
- self.command.plugins,
- shortdesc='Show the plugins in use.')
- self.register_command(
- 'presence',
- self.command.presence,
- usage='<JID> [type] [status]',
- desc="Send a directed presence to <JID> and using"
- " [type] and [status] if provided.",
- shortdesc='Send a directed presence.',
- completion=self.completion.presence)
- self.register_command(
- 'rawxml',
- self.command.rawxml,
- usage='<xml>',
- shortdesc='Send a custom xml stanza.')
- self.register_command(
- 'invite',
- self.command.invite,
- usage='<jid> <room> [reason]',
- desc='Invite jid in room with reason.',
- shortdesc='Invite someone in a room.',
- completion=self.completion.invite)
- self.register_command(
- 'impromptu',
- self.command.impromptu,
- usage='<jid> [jid ...]',
- desc='Invite specified JIDs into a newly created room.',
- shortdesc='Invite specified JIDs into newly created room.',
- completion=self.completion.impromptu)
- self.register_command(
- 'invitations',
- self.command.invitations,
- shortdesc='Show the pending invitations.')
- self.register_command(
- 'bookmarks',
- self.command.bookmarks,
- shortdesc='Show the current bookmarks.')
- self.register_command(
- 'remove_bookmark',
- self.command.remove_bookmark,
- usage='[jid]',
- desc="Remove the specified bookmark, or the "
- "bookmark on the current tab, if any.",
- shortdesc='Remove a bookmark',
- completion=self.completion.remove_bookmark)
- self.register_command(
- 'xml_tab', self.command.xml_tab, shortdesc='Open an XML tab.')
- self.register_command(
- 'runkey',
- self.command.runkey,
- usage='<key>',
- shortdesc='Execute the action defined for <key>.',
- completion=self.completion.runkey)
- self.register_command(
- 'self', self.command.self_, shortdesc='Remind you of who you are.')
- self.register_command(
- 'last_activity',
- self.command.last_activity,
- usage='<jid>',
- desc='Informs you of the last activity of a JID.',
- shortdesc='Get the activity of someone.',
- completion=self.completion.last_activity)
- self.register_command(
- 'ad-hoc',
- self.command.adhoc,
- usage='<jid>',
- shortdesc='List available ad-hoc commands on the given jid')
- self.register_command(
- 'reload',
- self.command.reload,
- shortdesc='Reload the config. You can achieve the same by '
- 'sending SIGUSR1 to poezio.')
+ for command in get_commands(self.command, self.completion, self.plugin_manager):
+ self.register_command(**command)
if config.get('enable_user_activity'):
self.register_command(
diff --git a/poezio/core/structs.py b/poezio/core/structs.py
index ae4ebe7d..5866b19f 100644
--- a/poezio/core/structs.py
+++ b/poezio/core/structs.py
@@ -5,8 +5,10 @@ from dataclasses import dataclass
from typing import Any, Callable, List, Dict
__all__ = [
- 'POSSIBLE_SHOW', 'Status',
- 'Command', 'Completion'
+ 'Command',
+ 'Completion'
+ 'POSSIBLE_SHOW',
+ 'Status',
]
POSSIBLE_SHOW = {