I’m trying to defeat click 8.x’s behavior on windows of expanding glob patterns by default. This seems straightforward for a multi-command where you define group. But I can’t figure out how to do it for a single command program. Take the following example saved as mycommand.py
:
import click
@click.command("mycommand")
@click.argument("filepattern", nargs=1, type=str)
def mycommand(filepattern):
print(filepattern)
if __name__ == "__main__":
mycommand()
If I have a directory full of, say Python files, if I invoke this as python mycommand.py somefile.py
, it will succeed as one value gets passed into filepattern
and it will echo somefile.py
.
If I invoke as python mycommand.py *.py
it fails with an error like:
Usage: mycommand.py [OPTIONS] FILEPATTERN
Try 'mycommand.py --help' for help.
Error: Got unexpected extra arguments (scratch.py mycommand.py ...)
I know there is an argument windows_expand_args
for a click.group
, but I can’t puzzle out how to get it to work for a single command program.