6

我正在尝试对多个文件使用单击。例如:

@cli.command("test")
@click.argument('input', type=click.File('rb'))
def test(input):
    with click.progressbar(input, label='READING') as bar:
        for x in bar:
            pass

当我做这样的事情时:

script test ~/ololo/*

我得到:

Error: Got unexpected extra arguments ( ... listing all files in folder ...)
4

1 回答 1

8

您需要使用nargs参数。如果设置为 -1,则接受无限数量的参数:http: //click.pocoo.org/6/arguments/#variadic-arguments

@cli.command("test")
@click.argument('input', nargs=-1, type=click.File('rb'))
def test(input):
    with click.progressbar(input, label='READING') as bar:
        for x in bar:
            pass
于 2016-01-13T10:08:51.233 回答