unioslo / mreg-cli

Command Line Interface for Mreg
GNU General Public License v3.0
2 stars 7 forks source link

Colorize diffs with Rich #268

Closed pederhan closed 4 months ago

pederhan commented 4 months ago

This PR adds color to the diff produced by ci/diff.py:

image

This is a stepping stone to eventually adding interactive diff reviewing similar to pytest --inline-snapshot=review:

image

Compatibility

I stored the terminal output of diff.py before and after the code changes, and they produce identical output (except diff_post has color when not redirected to a file):

# Before:
❯ python diff.py testsuite-result.json new_testsuite_log.json > diff_pre
# After:
❯ python diff.py testsuite-result.json new_testsuite_log.json > diff_post
❯ diff -s diff_pre diff_post
Files diff_pre and diff_post are identical
pederhan commented 4 months ago

Adding this functionality + reviewing in #270.