本文整理匯總了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