nebari icon indicating copy to clipboard operation
nebari copied to clipboard

[ENH] - allow to control colors in terminal

Open nkaretnikov opened this issue 2 years ago • 3 comments

Feature description

This is unreadable in a terminal with white background:

nebari init --help      

Provide an option to disable colors.

Some popular terminal configurations to test: ubuntu terminal, dark bg, white bg, solarized.

Value and/or benefit

See above.

Anything else?

6d01b048dd01e884d3a9f1d60ddebd4dbe96432e

nkaretnikov avatar Sep 22 '23 07:09 nkaretnikov

Yellow is the most problematic, but I'd prefer to just have --color=no. Because you never know what terminal config someone uses.

Screen Shot 2023-09-22 at 09 18 00

nkaretnikov avatar Sep 22 '23 07:09 nkaretnikov

Thanks for raising this with us @nkaretnikov! This is definitely something that will need to be sorted out.

iameskild avatar Oct 09 '23 16:10 iameskild

seems like in the code there are various places where either rich.print or console is used. Id suggest

  • find all the rich.print replace them with a corresponding console.print
  • when we pass in --color=no well just set all console.no_color = True
  • additionally we have to figure out where and what each rich/console s are used for

And then as a followup activity, we have to take out the direct color references eg [green][/green] and replace them with style themes/semantic tags eg [uri][/uri] as mentioned in #1478 . As in well leave those embedded stylings as is for now

@nkaretnikov @iameskild what do you guys think?

Edit:

  1. This is easiest to just set NO_COLOR env variable and rich will disable all color. (not Typer). Not ideal but seems to be the only way?
  2. There is no way to pass a rich.console to the typer.Typer constructor. Uncertain whether access to the typer console instance is accessible either.
  3. It may be possible to modify this with env variables with specific Themes just like typer/rich_utils.py does is the way to do it (STYLE_OPTION_ENVVAR) but it does seem that _get_rich_console seems to be instantiating a new console Theme all the time when the typer command gets rendered out.

abdulazizali77 avatar Jun 09 '24 00:06 abdulazizali77