wsw*_*wld 5 python python-click
我正在尝试使用click来存储多个文件.例如:
@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
Run Code Online (Sandbox Code Playgroud)
当我做这样的事情时:
script test ~/ololo/*
Run Code Online (Sandbox Code Playgroud)
我明白了:
Error: Got unexpected extra arguments ( ... listing all files in folder ...)
Run Code Online (Sandbox Code Playgroud)
你需要使用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
Run Code Online (Sandbox Code Playgroud)