gw_commands_pattern.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:groundwork 作者: useblocks 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号