Commit 0847643b authored by mathieui's avatar mathieui

Fix #2421 (load and unload several plugins)

parent d18fe6c4
...@@ -60,14 +60,14 @@ These commands work in *any* tab. ...@@ -60,14 +60,14 @@ These commands work in *any* tab.
Just disconnect from the server and exit poezio. Just disconnect from the server and exit poezio.
/load /load
**Usage:** ``/load <plugin name>`` **Usage:** ``/load <plugin name> [<other plugin> …]``
Load or reload a plugin. Load or reload one or several plugins.
/unload /unload
**Usage:** ``/unload <plugin name>`` **Usage:** ``/unload <plugin name> [<other plugin> …]``
Unload a plugin. Unload one or several plugins.
/plugins /plugins
List the loaded plugins. List the loaded plugins.
......
...@@ -797,25 +797,19 @@ def command_rawxml(self, arg): ...@@ -797,25 +797,19 @@ def command_rawxml(self, arg):
def command_load(self, arg): def command_load(self, arg):
""" """
/load <plugin> /load <plugin> [<otherplugin> …]
""" """
args = arg.split() args = arg.split()
if len(args) != 1: for plugin in args:
self.command_help('load') self.plugin_manager.load(plugin)
return
filename = args[0]
self.plugin_manager.load(filename)
def command_unload(self, arg): def command_unload(self, arg):
""" """
/unload <plugin> /unload <plugin> [<otherplugin> …]
""" """
args = arg.split() args = arg.split()
if len(args) != 1: for plugin in args:
self.command_help('unload') self.plugin_manager.unload(plugin)
return
filename = args[0]
self.plugin_manager.unload(filename)
def command_plugins(self, arg=''): def command_plugins(self, arg=''):
""" """
......
...@@ -1542,19 +1542,19 @@ class Core(object): ...@@ -1542,19 +1542,19 @@ class Core(object):
shortdesc=_('Cycle a range of rooms'), shortdesc=_('Cycle a range of rooms'),
completion=self.completion_server_cycle) completion=self.completion_server_cycle)
self.register_command('bind', self.command_bind, self.register_command('bind', self.command_bind,
usage=_(' <key> <equ>'), usage=_('<key> <equ>'),
desc=_("Bind a key to another key or to a “command”. For " desc=_("Bind a key to another key or to a “command”. For "
"example \"/bind ^H KEY_UP\" makes Control + h do the" "example \"/bind ^H KEY_UP\" makes Control + h do the"
" same same as the Up key."), " same same as the Up key."),
completion=self.completion_bind, completion=self.completion_bind,
shortdesc=_('Bind a key to another key.')) shortdesc=_('Bind a key to another key.'))
self.register_command('load', self.command_load, self.register_command('load', self.command_load,
usage=_('<plugin>'), usage=_('<plugin> [<otherplugin> …]'),
shortdesc=_('Load the specified plugin'), shortdesc=_('Load the specified plugin(s)'),
completion=self.plugin_manager.completion_load) completion=self.plugin_manager.completion_load)
self.register_command('unload', self.command_unload, self.register_command('unload', self.command_unload,
usage=_('<plugin>'), usage=_('<plugin> [<otherplugin> …]'),
shortdesc=_('Unload the specified plugin'), shortdesc=_('Unload the specified plugin(s)'),
completion=self.plugin_manager.completion_unload) completion=self.plugin_manager.completion_unload)
self.register_command('plugins', self.command_plugins, self.register_command('plugins', self.command_plugins,
shortdesc=_('Show the plugins in use.')) shortdesc=_('Show the plugins in use.'))
......
...@@ -110,7 +110,7 @@ class PluginManager(object): ...@@ -110,7 +110,7 @@ class PluginManager(object):
else: # 3.3 & > else: # 3.3 & >
loader = finder.find_module(name, load_path) loader = finder.find_module(name, load_path)
if not loader: if not loader:
self.core.information('Could not find plugin') self.core.information('Could not find plugin: %s' % name)
return return
module = loader.load_module() module = loader.load_module()
...@@ -311,13 +311,15 @@ class PluginManager(object): ...@@ -311,13 +311,15 @@ class PluginManager(object):
plugins_files = [name[:-3] for name in names if name.endswith('.py') plugins_files = [name[:-3] for name in names if name.endswith('.py')
and name != '__init__.py' and not name.startswith('.')] and name != '__init__.py' and not name.startswith('.')]
plugins_files.sort() plugins_files.sort()
return the_input.new_completion(plugins_files, 1, '', quotify=False) position = the_input.get_argument_position(quoted=False)
return the_input.new_completion(plugins_files, position, '', quotify=False)
def completion_unload(self, the_input): def completion_unload(self, the_input):
""" """
completion function that completes the name of the plugins that are loaded completion function that completes the name of the plugins that are loaded
""" """
return the_input.new_completion(sorted(self.plugins.keys()), 1, '', quotify=False) position = the_input.get_argument_position(quoted=False)
return the_input.new_completion(sorted(self.plugins.keys()), position, '', quotify=False)
def on_plugins_dir_change(self, new_value): def on_plugins_dir_change(self, new_value):
global plugins_dir global plugins_dir
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment