我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用click.CommandCollection()。
def init_cli(cli_obj, reset=False): if reset: global MANAGE_DICT MANAGE_DICT = {} sys.path.insert(0, '.') load_manage_dict_from_sys_args() cli.help = MANAGE_DICT.get( 'help_text', '{project_name} Interactive shell!' ).format(**MANAGE_DICT) load_groups(cli, MANAGE_DICT) load_commands(cli, MANAGE_DICT) manager = click.CommandCollection(help=cli.help, no_args_is_help=False) manager.add_source(cli) load_command_sources(manager, MANAGE_DICT) for item in MANAGE_DICT.get('disabled', []): cli.commands.pop(item, None) return manager
def main(): click.CommandCollection(sources=[cli(obj=ConfigParser.ConfigParser())])()