Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Color aliases for custom color support #1101

Merged
merged 1 commit into from Dec 16, 2022

Conversation

blacksails
Copy link
Contributor

@blacksails blacksails commented Dec 16, 2022

#1095 introduced custom color support. This PR improves the implementation, so that it doesn't rely on entering entire escape codes but instead it uses the color names and for the 256 color palette it uses their number.

Example of how this feature improves usablity when using a color scheme like solarized. Before this change the colors looks like this when using the solarized color scheme

Screenshot 2022-12-16 at 13 13 35

By setting the following envvars

export GINKGO_CLI_COLOR_RED="red"
export GINKGO_CLI_COLOR_ORANGE="bright-red"
export GINKGO_CLI_COLOR_CORAL="bright-magenta"
export GINKGO_CLI_COLOR_MAGENTA="magenta"
export GINKGO_CLI_COLOR_GREEN="green"
export GINKGO_CLI_COLOR_DARK_GREEN="green"
export GINKGO_CLI_COLOR_YELLOW="yellow"
export GINKGO_CLI_COLOR_LIGHT_YELLOW="yellow"
export GINKGO_CLI_COLOR_CYAN="cyan"
export GINKGO_CLI_COLOR_GRAY="bright-blue"
export GINKGO_CLI_COLOR_LIGHT_GRAY="bright-cyan" 
export GINKGO_CLI_COLOR_BLUE="blue"

The output now looks like this

Screenshot 2022-12-16 at 13 09 51

One could also chose to use the color numbers like (which also is needed to reference the 256 color palette).

export GINKGO_CLI_COLOR_RED="1"
export GINKGO_CLI_COLOR_ORANGE="9"
export GINKGO_CLI_COLOR_CORAL="13"
export GINKGO_CLI_COLOR_MAGENTA="5"
export GINKGO_CLI_COLOR_GREEN="2"
export GINKGO_CLI_COLOR_DARK_GREEN="2"
export GINKGO_CLI_COLOR_YELLOW="3"
export GINKGO_CLI_COLOR_LIGHT_YELLOW="3"
export GINKGO_CLI_COLOR_CYAN="6"
export GINKGO_CLI_COLOR_GRAY="12"
export GINKGO_CLI_COLOR_LIGHT_GRAY="14" 
export GINKGO_CLI_COLOR_BLUE="4"

This moves the custom color support away from the raw ASCI escapes and instead uses words for the standard 16 terminal colors or optionally 0-255 for the extended 256 color palette.

Besides the feature improvement a missing envvar unset in the tests was added.

fixes #1098

This moves the custom color support away from the raw ASCI escapes and
instead uses words for the standard 16 terminal colors or optionally
0-255 for the extended 256 color palette.

Also add missing envvar unset in the test
@onsi
Copy link
Owner

onsi commented Dec 16, 2022

looks good to me!

@onsi onsi merged commit 49fab7a into onsi:master Dec 16, 2022
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.

Support shorter aliases for color escape codes
2 participants