How would this feature be useful?
Supporting completion of environment variables names would improve the user experience of the CLI command pipx environment --value VARIABLE.
Describe the solution you'd like
Delegate the work to argcomplete by configuring argparse's built-in support for choices with the canonical list of ENVIRONMENT_VARIABLES that this project already defines.
More specifically, refactor this method invocation (which defines the CLI argument pipx environment --value VARIABLE) to include the Python argument choices=ENVIRONMENT_VARIABLES, i.e.:
p.add_argument("--value", "-V", choices=ENVIRONMENT_VARIABLES, metavar="VARIABLE", help="Print the value of the variable.")
Describe alternatives you've considered
I have not considered any alternatives because the add_argument(choices=...) mechanism is both sufficient and satisfactory on account of being already built-in (i.e. readily-available, reliably implemented, and officially recommended). Similar logic applies to re-using ENVIRONMENT_VARIABLES for the sake of DRY code.
However, it may be necessary to define an additional constant (e.g. VIRTUAL_ENVIRONMENT_VARIABLES) to represent the following derived_values that can be queried via pipx environment --value VARIABLE but whose names are not in ENVIRONMENT_VARIABLES:
- PIPX_LOCAL_VENVS
- PIPX_LOG_DIR
- PIPX_STANDALONE_PYTHON_CACHE_DIR
- PIPX_TRASH_DIR
- PIPX_VENV_CACHEDIR
Reference:
ENVIRONMENT_VARIABLES values |
derived_values keys |
| PIPX_BIN_DIR |
PIPX_BIN_DIR |
| PIPX_DEFAULT_PYTHON |
PIPX_DEFAULT_PYTHON |
| PIPX_FETCH_MISSING_PYTHON |
|
| PIPX_GLOBAL_BIN_DIR |
|
| PIPX_GLOBAL_HOME |
|
| PIPX_GLOBAL_MAN_DIR |
|
| PIPX_HOME |
PIPX_HOME |
| PIPX_HOME_ALLOW_SPACE |
PIPX_HOME_ALLOW_SPACE |
|
PIPX_LOCAL_VENVS |
|
PIPX_LOG_DIR |
| PIPX_MAN_DIR |
PIPX_MAN_DIR |
| PIPX_SHARED_LIBS |
PIPX_SHARED_LIBS |
|
PIPX_STANDALONE_PYTHON_CACHEDIR |
|
PIPX_TRASH_DIR |
|
PIPX_VENV_CACHEDIR |
| USE_EMOJI |
USE_EMOJI |
How would this feature be useful?
Supporting completion of environment variables names would improve the user experience of the CLI command
pipx environment --value VARIABLE.Describe the solution you'd like
Delegate the work to argcomplete by configuring argparse's built-in support for choices with the canonical list of
ENVIRONMENT_VARIABLESthat this project already defines.More specifically, refactor this method invocation (which defines the CLI argument
pipx environment --value VARIABLE) to include the Python argumentchoices=ENVIRONMENT_VARIABLES, i.e.:Describe alternatives you've considered
I have not considered any alternatives because the
add_argument(choices=...)mechanism is both sufficient and satisfactory on account of being already built-in (i.e. readily-available, reliably implemented, and officially recommended). Similar logic applies to re-usingENVIRONMENT_VARIABLESfor the sake of DRY code.However, it may be necessary to define an additional constant (e.g.
VIRTUAL_ENVIRONMENT_VARIABLES) to represent the followingderived_valuesthat can be queried viapipx environment --value VARIABLEbut whose names are not inENVIRONMENT_VARIABLES:Reference:
ENVIRONMENT_VARIABLESvaluesderived_valueskeys