Environment Variables #552
-
First Check
Commit to Help
Example Code@app.command(short_help="Creates Secrets")
def create(
name: str = typer.Option(None, "--token-name", help="The name of the token."),
auth: str = typer.Option(
None,
"--auth",
envvar="AUTH_TOKEN",
help=".....",
),
config: Optional[Path] = typer.Option(
None,
exists=True,
readable=True,
file_okay=True,
resolve_path=True,
),
): DescriptionIn the above example function definition, is there a way to make the argument environment variable auth key envvar="AUTH_TOKEN" to be defined by the user instead, rather than hardcoding AUTH_TOKEN ? Operating SystemWindows Operating System DetailsNo response Typer Version0.7.0 Python VersionPython 3.11.0 Additional ContextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Have you considered changing your command's API to take an environment variable name as an option and then read from that environment variable internal to the command? That seems like the clearest way to do things. I don't think you could otherwise make one |
Beta Was this translation helpful? Give feedback.
Have you considered changing your command's API to take an environment variable name as an option and then read from that environment variable internal to the command? That seems like the clearest way to do things. I don't think you could otherwise make one
--auth
option mean two different things cleanly.