Python单击模块不使用连字符参数

Python单击模块不使用连字符参数,python,command-line-interface,python-click,Python,Command Line Interface,Python Click,我尝试使用单击模块将多个参数传递给python脚本(opsgit),如下所示: import click @click.command() @click.argument('arguments', nargs=-1) def cli(arguments): """CLI for git""" cmd = create_command(arguments) _execute_command(cmd) 执行此命令

我尝试使用
单击
模块将多个参数传递给python脚本(
opsgit
),如下所示:

import click

@click.command()
@click.argument('arguments', nargs=-1)
def cli(arguments):
    """CLI for git"""
    cmd = create_command(arguments)
    _execute_command(cmd)
执行此命令行时:

$opsgit git checkout-b pvt\u测试
我得到这个错误:

用法:opsgit git[OPTIONS][ARGUMENTS]。。。 请尝试“opsgit git--help”以获取帮助。 错误:没有这样的选项:-b
有人能告诉我如何解决这个问题吗?

您缺少
忽略\u未知\u选项
标志。下面是添加了标志的示例。有关如何使用
nargs
的更多信息,请查看

import click

@click.command(context_settings=dict(
    ignore_unknown_options=True,
))
@click.argument('arguments', nargs=-1)
def cli(arguments):
    """CLI for git"""
    cmd = click.create_command(arguments)
    _execute_command(cmd)