Textualize / rich-cli

Rich-cli is a command line toolbox for fancy output in the terminal
https://www.textualize.io
MIT License
3.1k stars 77 forks source link

Feature request: support setting `--hyperlinks` via the `RICH_HYPERLINKS` environment variable #62

Open andelink opened 2 years ago

andelink commented 2 years ago

Hi team, I've just discovered Rich and this CLI and I'm a big fan. Thanks for making this such an awesome tool!

While using it, I quickly noticed a desire to set-and-forget the --hyperlinks flag so I would not need to pass it every time. So making this an official request and have opened a PR for your review:

This is the only change:

https://github.com/Textualize/rich-cli/blob/bc4da55dbabf85a7c1328f3c84e9021da618e650/src/rich_cli/__main__.py#L378

Hopefully you can take a look when you have a chance. Thanks!

andelink commented 2 years ago

Hey @willmcgugan, do you have any thoughts on this? PR:

willmcgugan commented 2 years ago

Seems reasonable. There are probably a few other env vars that could be added. Such as default theme.

andelink commented 2 years ago

I believe a default theme is already supported via RICH_THEME:

https://github.com/Textualize/rich-cli/blob/0721cb196661687d8ecd9af4baf48576b240c978/src/rich_cli/__main__.py#L350-L356


There are a few more listed in the rich docs:

Rich respects some standard environment variables.

Setting the environment variable TERM to "dumb" or "unknown" will disable color/style and some features that require moving the cursor, such as progress bars.

If the environment variable NO_COLOR is set, Rich will disable all color in the output.

If width/height arguments are not explicitly provided as arguments to Console then the environment variables COLUMNS/LINES can be used to set the console width/height. JUPYTER_COLUMNS/JUPYTER_LINES behave similarly and are used in Jupyter.