summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/plugin.py10
-rw-r--r--src/plugin_manager.py11
2 files changed, 12 insertions, 9 deletions
diff --git a/src/plugin.py b/src/plugin.py
index bd5c88be..537f7b61 100644
--- a/src/plugin.py
+++ b/src/plugin.py
@@ -113,12 +113,13 @@ class BasePlugin(object, metaclass=SafetyMetaclass):
def unload(self):
self.cleanup()
- def add_command(self, name, handler, help, completion=None):
+ def add_command(self, name, handler, help, completion=None, short='', usage=''):
"""
Add a global command.
You cannot overwrite the existing commands.
"""
- return self.plugin_manager.add_command(self.__module__, name, handler, help, completion)
+ return self.plugin_manager.add_command(self.__module__, name, handler, help,
+ completion=completion, short=short, usage=usage)
def del_command(self, name):
"""
@@ -151,11 +152,12 @@ class BasePlugin(object, metaclass=SafetyMetaclass):
"""
return self.plugin_manager.del_tab_key(self.__module__, tab_type, key)
- def add_tab_command(self, tab_type, name, handler, help, completion=None):
+ def add_tab_command(self, tab_type, name, handler, help, completion=None, short='', usage=''):
"""
Add a command only for a type of tab.
"""
- return self.plugin_manager.add_tab_command(self.__module__, tab_type, name, handler, help, completion)
+ return self.plugin_manager.add_tab_command(self.__module__, tab_type, name, handler, help,
+ completion=completion, short=short, usage=usage)
def del_tab_command(self, tab_type, name):
"""
diff --git a/src/plugin_manager.py b/src/plugin_manager.py
index a1782e1b..5f848ec2 100644
--- a/src/plugin_manager.py
+++ b/src/plugin_manager.py
@@ -12,6 +12,7 @@ import sys
import logging
from gettext import gettext as _
+import core
import tabs
from config import config
@@ -126,7 +127,7 @@ class PluginManager(object):
log.debug("Could not unload plugin: \n%s", traceback.format_exc())
self.core.information("Could not unload plugin: %s" % e, 'Error')
- def add_command(self, module_name, name, handler, help, completion=None):
+ def add_command(self, module_name, name, handler, help, completion=None, short='', usage=''):
"""
Add a global command.
"""
@@ -134,8 +135,8 @@ class PluginManager(object):
raise Exception(_("Command '%s' already exists") % (name,))
commands = self.commands[module_name]
- commands[name] = (handler, help, completion)
- self.core.commands[name] = (handler, help, completion)
+ commands[name] = core.Command(handler, help, completion, short, usage)
+ self.core.commands[name] = commands[name]
def del_command(self, module_name, name):
"""
@@ -146,7 +147,7 @@ class PluginManager(object):
if name in self.core.commands:
del self.core.commands[name]
- def add_tab_command(self, module_name, tab_type, name, handler, help, completion=None):
+ def add_tab_command(self, module_name, tab_type, name, handler, help, completion=None, short='', usage=''):
"""
Add a command only for a type of Tab.
"""
@@ -157,7 +158,7 @@ class PluginManager(object):
if not t in commands:
commands[t] = []
commands[t].append((name, handler, help, completion))
- tab_type.plugin_commands[name] = (handler, help, completion)
+ tab_type.plugin_commands[name] = core.Command(handler, help, completion, short, usage)
for tab in self.core.tabs:
if isinstance(tab, tab_type):
tab.update_commands()