def register(self, command, description, function, params=[], plugin=None):
"""
Registers a new command, which can be used on a command line interface (cli).
:param command: Name of the command
:param description: Description of the command. Is used as help message on cli
:param function: function reference, which gets invoked if command gets called.
:param params: list of click options and arguments
:param plugin: the plugin, which registered this command
:return: command object
"""
if command in self._commands.keys():
raise CommandExistException("Command %s already registered by %s" % (command,
self._commands[command].plugin.name))
new_command = Command(command, description, params, function, plugin)
self._commands[command] = new_command
self._click_root_command.add_command(new_command.click_command)
self.log.debug("Command registered: %s" % command)
return new_command
评论列表
文章目录