-
-
Notifications
You must be signed in to change notification settings - Fork 779
Open
Labels
featureNew feature, enhancement or requestNew feature, enhancement or request
Description
First Check
- I added a very descriptive title to this issue.
- I used the GitHub search to find a similar issue and didn't find it.
- I searched the Typer documentation, with the integrated search.
- I already searched in Google "How to X in Typer" and didn't find any information.
- I already read and followed all the tutorial in the docs and didn't find an answer.
- I already checked if it is not related to Typer but to Click.
Commit to Help
- I commit to help with one of those options 👆
Example Code
import typer
cli = typer.Typer()
@cli.command()
def configure(file: str = typer.Argument("", envvar="FILE")):
print("Configure could be written more succintly if envvar=FILE is created by convention")
Description
We usually define arguments and options as environment variables. We tipically use a simple convention where param
becomes PARAM
and some_param
becomes SOME_PARAM
. That adds a bit of boilerplate to method definitions. I would like typer
to accept environment variables that match argument and options names by conventions.
I can try to make a pull request if you find this behavior reasonable.
Wanted Solution
I would like that if envvar
is not fullfilled in typer
, it tries to get that environment variable by convention.
I could try to make a pull request with this idea if you find it reasonable.
Wanted Code
import typer
cli = typer.Typer()
@cli.command()
def configure(file: str)):
print("Configure accepts FILE as envvar")
Alternatives
No response
Operating System
Linux
Operating System Details
No response
Typer Version
0.7.0
Python Version
Python 3.8.10
Additional Context
No response
alexreg, emcd, AiyionPrime, guyb1997 and dvonessen
Metadata
Metadata
Assignees
Labels
featureNew feature, enhancement or requestNew feature, enhancement or request