Since click 8.0, the value(s) provided on the command line for a nargs=-1 argument are ignored if the argument has envvar set.
Example:
#!/usr/bin/env python
import click
@click.command()
@click.argument("foo", nargs=-1, envvar="FOO")
def cli(foo):
click.echo(foo)
if __name__ == "__main__":
cli()
$ ./clickbug arg1 arg2
()
When arguments are passed on the command line, the foo value remains empty. Removing the envvar option makes it work again. Values from the environment variable are picked up, though. Reverting to click<8 also fixes the problem.
The cause of the bug is possibly here: The incoming value (which at this point still contains the correct arguments) is overwritten with None if nargs is -1 and the argument has an envvar set.
Environment:
- Python version: 3.8.5
- Click version: 8.0.0
Since click 8.0, the value(s) provided on the command line for a nargs=-1 argument are ignored if the argument has
envvarset.Example:
When arguments are passed on the command line, the
foovalue remains empty. Removing theenvvaroption makes it work again. Values from the environment variable are picked up, though. Reverting toclick<8also fixes the problem.The cause of the bug is possibly here: The incoming
value(which at this point still contains the correct arguments) is overwritten withNoneifnargsis -1 and the argument has an envvar set.Environment: