8000 gh-131952: Add color to the `json` CLI by tomasr8 · Pull Request #132126 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-131952: Add color to the json CLI #132126

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

Merged
merged 32 commits into from
Apr 19, 2025
Merged
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
cae293f
Add color to the json.tool CLI output
tomasr8 Apr 5, 2025
1854ae5
Add news entry
tomasr8 Apr 5, 2025
ee39cb2
Fix escaped quotes
tomasr8 Apr 5, 2025
5e726ee
Fix tests
tomasr8 Apr 5, 2025
848a7be
Fix the tests for real this time
tomasr8 Apr 5, 2025
8d90ccb
Fix tests on Windows
tomasr8 Apr 5, 2025
93e4306
Sort imports
tomasr8 Apr 5, 2025
f8d697a
Fix string regex
tomasr8 Apr 5, 2025
429e350
Handle NaN & Infinity
tomasr8 Apr 6, 2025
0abe76a
Use only digits in number regex
tomasr8 Apr 6, 2025
1acd35d
Remove non-greedy matching in string regex
tomasr8 Apr 6, 2025
691aecd
Test unicode
tomasr8 Apr 6, 2025
5afac97
Pass the file to `can_colorize`
tomasr8 Apr 6, 2025
911f75f
Make the test file runnable
tomasr8 Apr 6, 2025
4c27be7
Use force_not_colorized
tomasr8 Apr 6, 2025
18ce6fa
Remove unused variable
tomasr8 Apr 6, 2025
18f7ae5
🦭
tomasr8 Apr 6, 2025
b5157af
Add a comment to the color regex
tomasr8 Apr 6, 2025
d7287e2
Move helper functions to the start
tomasr8 Apr 6, 2025
177107b
Make helper functions private
tomasr8 Apr 6, 2025
8000
b7589be
Prefer global functions
tomasr8 Apr 6, 2025
e744290
Remove redundant comments
tomasr8 Apr 6, 2025
fac39c7
Improve news entry
tomasr8 Apr 6, 2025
4f399be
Highlight keys in a different color
tomasr8 Apr 15, 2025
8bd0a36
Improve color contrast
tomasr8 Apr 15, 2025
37d4c08
Tone down the colors a bit
tomasr8 Apr 15, 2025
1e6f4ea
Use bold colors & fix tests
tomasr8 Apr 15, 2025
cc92518
Use default color for numbers
tomasr8 Apr 19, 2025
4fc5e27
Add What's New entry
tomasr8 Apr 19, 2025
a489649
Simplify code
tomasr8 Apr 19, 2025
789ca88
Lint fix
tomasr8 Apr 19, 2025
ce75f86
Fix typo
tomasr8 Apr 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Simplify code
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
  • Loading branch information
tomasr8 and AA-Turner authored Apr 19, 2025
commit a489649070e1a902479f903bedb9a0eb9e86929d
3 changes: 1 addition & 2 deletions Lib/json/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@


def _replace_match_callback(match):
for key in _colors:
for key, color in _colors.items():
if m := match.group(key):
color = _colors[key]
return f"{color}{m}{ANSIColors.RESET}"
return match.group()

Expand Down
Loading
0