From 2ea8673a0408bb3151ea8fdb4045814d88e770bb Mon Sep 17 00:00:00 2001 From: mathieui Date: Sun, 6 Jan 2013 17:36:14 +0100 Subject: Improve the help system (#1986) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TODO: change the plugin API to take advantage of this This change is backwards-compatible (as in “should not break anything”) --- src/core.py | 218 +++++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 173 insertions(+), 45 deletions(-) (limited to 'src/core.py') diff --git a/src/core.py b/src/core.py index 646e8188..3d5f8268 100644 --- a/src/core.py +++ b/src/core.py @@ -102,6 +102,7 @@ possible_show = {'available':None, } Status = collections.namedtuple('Status', 'show message') +Command = collections.namedtuple('Command', 'func desc comp short usage') class Core(object): """ @@ -156,42 +157,8 @@ class Core(object): # a completion function, taking a Input as argument. Can be None) # The completion function should return True if a completion was # made ; False otherwise - self.commands = { - 'help': (self.command_help, '\_o< KOIN KOIN KOIN', self.completion_help), - 'join': (self.command_join, _("Usage: /join [room_name][@server][/nick] [password]\nJoin: 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"), self.completion_join), - 'exit': (self.command_quit, _("Usage: /exit\nExit: Just disconnect from the server and exit poezio."), None), - 'quit': (self.command_quit, _("Usage: /quit\nQuit: Just disconnect from the server and exit poezio."), None), - 'next': (self.rotate_rooms_right, _("Usage: /next\nNext: Go to the next room."), None), - 'prev': (self.rotate_rooms_left, _("Usage: /prev\nPrev: Go to the previous room."), None), - 'win': (self.command_win, _("Usage: /win \nWin: Go to the specified room."), self.completion_win), - 'w': (self.command_win, _("Usage: /w \nW: Go to the specified room."), self.completion_win), - 'move_tab': (self.command_move_tab, _("Usage: /move_tab \nMove Tab: Insert the tab at the position of . 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."), self.completion_move_tab), - 'show': (self.command_status, _('Usage: /show [status message]\nShow: Sets your availability and (optionally) your status message. The argument is one of \"available, chat, away, afk, dnd, busy, xa\" and the optional [status message] argument will be your status message.'), self.completion_status), - 'status': (self.command_status, _('Usage: /status [status message]\nStatus: Sets your availability and (optionally) your status message. The argument is one of \"available, chat, away, afk, dnd, busy, xa\" and the optional [status message] argument will be your status message.'), self.completion_status), - 'bookmark_local': (self.command_bookmark_local, _("Usage: /bookmark_local [roomname][/nick] [password]\nBookmark 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 syntaxe 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)"), self.completion_bookmark_local), - 'bookmark': (self.command_bookmark, _("Usage: /bookmark [roomname][/nick] [autojoin] [password]\nBookmark: 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 syntaxe as /join. Type /help join for syntaxe 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)"), self.completion_bookmark), - 'set': (self.command_set, _("Usage: /set [plugin|][section]