[Python] Get Click to not expand variables in argument

Discussão em 'Python' iniciado por Stack, Janeiro 25, 2025.

  1. Stack

    Stack Membro Participativo

    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?

    Continue reading...

Compartilhe esta Página