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

Colorize json values #334

Closed
gavv opened this issue Mar 10, 2023 · 6 comments
Closed

Colorize json values #334

gavv opened this issue Mar 10, 2023 · 6 comments
Assignees
Labels
feature New feature or request good first issue Good for newcomers help wanted Contributions are welcome
Milestone

Comments

@gavv
Copy link
Owner

gavv commented Mar 10, 2023

Follow-up for #161.

Currently defaultFailureTemplate colorizes expected/actual/reference as follows:

{{ .Actual | indent | color .EnableColors "HiMagenta" }}

The following improvement is suggested:

  • add new function "colorjson" to defaultTemplateFuncs
  • if colors are disabled, the function will return original value
  • the function will try to parse value as json
  • if value is not json, the function just returns original value
  • if value is json, the function colorizes it using https://github.com/TylerBrock/colorjson
  • it uses custom color schema; I suggest: HiMagenta for string; Cyan for number, bool, null; default for key (not too much different colors, readable on dark and light background, and aligns with current colors schema)

For "delta", let's always use Cyan, like we use Cyan for all numbers in the color schema suggested above.

Related: #335, #343.

@gavv gavv added feature New feature or request help wanted Contributions are welcome good first issue Good for newcomers labels Mar 10, 2023
This was referenced Mar 10, 2023
@fbirn
Copy link

fbirn commented Mar 10, 2023

Hello, i would like to look into this and try to implement it!

@gavv
Copy link
Owner Author

gavv commented Mar 10, 2023

You're welcome, thanks!

@gavv
Copy link
Owner Author

gavv commented Apr 2, 2023

@fbirn Hi! Do you still have plans on this?

@gavv gavv added the waiting reply Waiting for reply from reporter or contributor label Apr 2, 2023
@dminkovski
Copy link
Contributor

@gavv Hello, I would love to take a shot at this if you do not mind :)

@gavv
Copy link
Owner Author

gavv commented Apr 26, 2023

@dminkovski Thanks!

@gavv gavv assigned dminkovski and unassigned fbirn Apr 26, 2023
@gavv gavv removed the waiting reply Waiting for reply from reporter or contributor label Apr 26, 2023
@gavv
Copy link
Owner Author

gavv commented Oct 2, 2023

Landed

@gavv gavv closed this as completed Oct 2, 2023
@gavv gavv added this to the v2 milestone Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request good first issue Good for newcomers help wanted Contributions are welcome
Projects
None yet
Development

No branches or pull requests

3 participants