Uh oh!
There was an error while loading. Please reload this page.
gh-131952: Add color to the json CLI - #132126
Conversation
Uh oh!
There was an error while loading. Please reload this page.
StanFromIreland
left a comment
There was a problem hiding this comment.
How much of a performance impact does this have?
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
It doesn't matter here. |
tomasr8
commented
Apr 5, 2025
I think we might not need that, |
json.tool CLI.json.tool CLIpicnixz
commented
Apr 5, 2025
What about CLIs? they would be broken if data is piped? |
tomasr8
commented
Apr 5, 2025
AFAIU they wouldn't (and local testing confirms that), see this comment from Hugo: #131952 (comment) |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
@tomasr8 thank you for taking the time to look into it. couple of notes regarding the keys 1) could you make them a different color from the string values? 2) could you make them bold? this is what jq does and i think it provides a good ux https://static1.howtogeekimages.com/wordpress/wp-content/uploads/2020/01/5-7.png |
tomasr8
commented
Apr 6, 2025
That should be in theory possible, we can distinguish keys from string literals since keys are always followed by |
| with_colors = can_colorize() | ||
There was a problem hiding this comment.
This variable isn't doing much, shall we just call the function directly?
There was a problem hiding this comment.
I may have been too cautious here. Without the variable, the function would be called in a loop and I was worried the result could change in between invocations, though that is really unlikely. If you prefer I can remove it?
There was a problem hiding this comment.
Actually, I applied your other suggestion which already removed it so never mind 😄
There was a problem hiding this comment.
No, that's a good point: there could be a lot of objs as JSONL files can be quite long. Let's add with_colors back, but just outside the loop.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
tomasr8
commented
Apr 15, 2025
AA-Turner
commented
Apr 15, 2025
The green and cyan colours here look bad on the white background, which is the default for Windows Terminal, PyCharm's in-built terminal, etc. Could you darken them? |
tomasr8
commented
Apr 15, 2025
AA-Turner
commented
Apr 15, 2025
I also prefer the bold version, thanks. A |
tomasr8
commented
Apr 15, 2025
Thanks for your feedback! I think it looks much better now :) I added the bold colors and updated tests. Would you mind taking another look? |
raztd
commented
Apr 16, 2025
i like the colors. one small request: could you bold the keys and leave the values regular? that's how jq does it https://static1.howtogeekimages.com/wordpress/wp-content/uploads/2020/01/5-7.png |
tomasr8
commented
Apr 16, 2025
I think I prefer the bold colors. In my opinion, they are more legible when bold, especially with the light theme. |
raztd
commented
Apr 16, 2025
in the last pair of screenshots, i see only the values as bold. the keys look regular. my proposal was to invert those. or do you want to make the keys bold, too? i think that could work |
Uh oh!
There was an error while loading. Please reload this page.
hugovk
commented
Apr 17, 2025
hugovk
commented
Apr 17, 2025
Please could you also add this to What's New, and mention the colour env vars, like the other similar entries? |
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
tomasr8
commented
Apr 19, 2025
Added - I reused your entry from the calendar module ;) |
Uh oh!
There was an error while loading. Please reload this page.
















Example:
I'm open to changing the colors. For now it's green for strings, yellow for numbers and cyan for true/false/null.