You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
importtypercli=typer.Typer()
@cli.command()defconfigure(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
importtypercli=typer.Typer()
@cli.command()defconfigure(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
The text was updated successfully, but these errors were encountered:
@raphaelauv, thanks for the idea. I tried the approach, and still see two mean shortcomings:
it only work for options
it must be set per-command. I tried typer.Typer(context_settings={ 'auto_envvar_prefix': 'TEST' }) with no success.
Hence, no much boilerplate is avoided.
It might make sense to push the addition of auto_envar_prefix as a global setting for click. Then, typer would only have to expose that setting in Typer constructor.
I already checked if it is not related to Typer but to Click, but I'm not so sure now 😅
@alexreg, thanks also for your code example. I prefer though to stick to maintained branches of libraries.
@alexreg No problem. I mean, mine is actively maintained, just not the official/original version, of course. I forked it when there had not been any activity here for a very long time. These days it's diverged a bit, though – the main point of its existence is to support Cloup as the foundation rather than merely Click. What you can perhaps do, if it suits you, is take my commit for this feature and try to merge it into the main Click branch, since that part of the codebase hadn't diverged anyway, as far as I recall.
First Check
Commit to Help
Example Code
Description
We usually define arguments and options as environment variables. We tipically use a simple convention where
param
becomesPARAM
andsome_param
becomesSOME_PARAM
. That adds a bit of boilerplate to method definitions. I would liketyper
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 intyper
, 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
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
The text was updated successfully, but these errors were encountered: