本文整理汇总了Python中click.CommandCollection方法的典型用法代码示例。如果您正苦于以下问题:Python click.CommandCollection方法的具体用法?Python click.CommandCollection怎么用?Python click.CommandCollection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类click
的用法示例。
在下文中一共展示了click.CommandCollection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_completion
# 需要导入模块: import click [as 别名]
# 或者: from click import CommandCollection [as 别名]
def test_completion():
@click.group()
def foo_group():
pass
@foo_group.command()
def foo_cmd():
pass
@click.group()
def foobar_group():
pass
@foobar_group.command()
def foobar_cmd():
pass
c = ClickCompleter(click.CommandCollection(sources=[foo_group, foobar_group]))
completions = list(c.get_completions(Document(u"foo")))
assert set(x.text for x in completions) == set([u"foo_cmd", u"foobar_cmd"])
示例2: init_cli
# 需要导入模块: import click [as 别名]
# 或者: from click import CommandCollection [as 别名]
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