Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Click to not expand variables in argument

I have a simple Click app like this:

import click

@click.command()
@click.argument('message')
def main(message: str):
    click.echo(message)

if __name__ == '__main__':
    main()

When you pass an environment variable in the argument, it expands it:

➜  Desktop python foo.py '$M0/.viola/2025-01-25-17-20-23-307878'
M:/home/ramrachum/.viola/2025-01-25-17-20-23-307878

Note that I used single quotes above, so my shell is not expanding the environment variable, Click does. How do I get Click to not expand it?

like image 559
Ram Rachum Avatar asked Sep 29 '25 09:09

Ram Rachum


1 Answers

The solution is to pass windows_expand_args=False when calling the main command.

like image 112
Ram Rachum Avatar answered Oct 02 '25 00:10

Ram Rachum



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!