Open frederikaalund opened 4 years ago
I didn't read your request carefully enough at first, and assumed it wasn't possible to use Click's autoenv at all in Typer.
I'd also like to be able to enable autoenv for arguments, but for any other googlers like me, here's how you can use autoenv with options at least.
app = typer.Typer(add_completion=False)
@app.command(context_settings={ 'auto_envvar_prefix': 'TEST' })
def main(hello = typer.Option('world')):
print(hello)
app()
Results in
Usage: test.py [OPTIONS]
Options:
--hello TEXT [env var: TEST_HELLO; default: world]
--help Show this message and exit.
Currently,
allow_from_autoenv
is not supported for CLI arguments. I'd like to see that support added.I guess that we also need to add
auto_envvar_prefix
to theTyper
constructor for it to make sense.Ideally, I'd like to have a global option (
Typer
constructor argument) that simply enables the autoenv functionality for allTyper.Option
instances. I guess that is a separate feature request.