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
$ python ./multiple_envvars.py --help
Usage: multiple_envvars.py [OPTIONS]
Options:
--flag / --no-flag [env var: FlAg, sUper; default: no-flag]
--help Show this message and exit.
Now let's try a couple of different envvars:
$ FlAg=1 python ./multiple_envvars.py
Flag value: True
$ FlAg=0 python ./multiple_envvars.py
Flag value: False
$ sUper=1 python ./multiple_envvars.py
Flag value: True
$ sUper=0 python ./multiple_envvars.py
Flag value: False
$ yo_FLAG=1 python ./multiple_envvars.py
Flag value: False
$ YO_FLAG=1 python ./multiple_envvars.py
Flag value: True
$ YO_FLAG=0 python ./multiple_envvars.py
Flag value: False
The surprise here is the discovery process of the auto-generated YO_FLAG. I expected it to respect the case-sensitivity of others. but everything auto-generated is uppercased.
So I wonder if we should enforce upper-casing all env vars, whatever their source.
And additionally, shouldn't we add the auto-generated YO_FLAG to the help screen to improve discoverability?
For reference, I ran these test on macOS / zsh, and with the latest click 8.3.1.
The text was updated successfully, but these errors were encountered:
kdeldycke
added a commit
to kdeldycke/click-extra
that referenced
this issue
Apr 5, 2023
Things are a little bit messier than I initially expected.
For instance, if I register explicitly the yo_FLAG as an environment variable on the option, it is properly recognised with its own particular mixed-case. Which highlight the difference of treatment between registered envvar and auto-generated envvar.
Environment variables are case sensistive except on Windows. Traditionally, variables are all uppercase, lowercase is usually only seen inside shell scripts. I feel like you're overthinking something here, there's nothing to fix regarding case.
Here is a simple CLI that mixes auto-generated and multiple environment variables:
This produces the following help screen:
Now let's try a couple of different envvars:
The surprise here is the discovery process of the auto-generated
YO_FLAG
. I expected it to respect the case-sensitivity of others. but everything auto-generated is uppercased.So I wonder if we should enforce upper-casing all env vars, whatever their source.
And additionally, shouldn't we add the auto-generated
YO_FLAG
to the help screen to improve discoverability?For reference, I ran these test on macOS / zsh, and with the latest
click 8.3.1
.The text was updated successfully, but these errors were encountered: