Skip to content

Override formatter colors from envvars#1095

Merged
onsi merged 2 commits into
onsi:masterfrom
blacksails:override-formatter-colors-from-envvars
Dec 14, 2022
Merged

Override formatter colors from envvars#1095
onsi merged 2 commits into
onsi:masterfrom
blacksails:override-formatter-colors-from-envvars

Conversation

@blacksails

Copy link
Copy Markdown
Contributor

This allows a user to set environment variables
GINKGO_CLI_COLOR_<color> with asci code overrides. This helps a lot when the colorscheme that you are using doesn't play well with the colors from the 256 color scheme which currently is hard coded.

Example GINKGO_CLI_COLOR_RED=$'\x1b[31m' ginkgo will use the red from the 8bit colors configured in the terminal.

This allows a user to set environment variables
`GINKGO_CLI_COLOR_<color>` with asci code overrides. This helps a lot
when the colorscheme that you are using doesn't play well with the
colors from the 256 color scheme which currently is hard coded.

Example `GINKGO_CLI_COLOR_RED=$'\x1b[31m' ginkgo` will use the red from
the 8bit colors configured in the terminal.
@blacksails

blacksails commented Dec 14, 2022

Copy link
Copy Markdown
Contributor Author

I dont nessesarily expect this to get merged as-is, but I would love an option to be able to change the colors of the terminal output. I am open to any input with regards to how this could be done differently.

The formatter testsuite currently fails if environment variables are overridden. I guess the before each needs to unset the environment variables to ensure that the tests give the expected results. Fixed in 7b768db

@blacksails blacksails changed the title Override environment formatter colors from envvars Override formatter colors from envvars Dec 14, 2022
@onsi

onsi commented Dec 14, 2022

Copy link
Copy Markdown
Owner

hey there - longer term my plan is to add support for some sort of .ginkgoconfig file or something that would be a natural place for something like this. For now environment variables seem fine but I'd like to reserve the right to deprecate them at some point and transition to a config file based approached.

Happy to pull this in once CI goes green, with those caveats.

@onsi onsi merged commit 60240d1 into onsi:master Dec 14, 2022
@blacksails

blacksails commented Dec 15, 2022

Copy link
Copy Markdown
Contributor Author

@onsi Yea this could also be better implemented.

The following values would be nice to map in order to make configuration way easier.

For the standard 16 colors
red => \x1b[31m
1 => \x1b[31m
bright-red => \x1b[31;1m
8 => \x1b[31;1m

For extended 256 colors
16 => \x1b[38;5;16m

@blacksails blacksails deleted the override-formatter-colors-from-envvars branch December 15, 2022 16:37
@onsi

onsi commented Dec 15, 2022

Copy link
Copy Markdown
Owner

hey, i think that's fine - but perhaps i'm not following? are you planning on another PR to support those aliases?

@blacksails

Copy link
Copy Markdown
Contributor Author

@onsi yea will do it today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants