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

Force rich to use color codes when pretty printing #1821

Merged

Conversation

micahellison
Copy link
Member

Fixes #1819.

When piping, rich's default behavior is to suppress color codes. This is very useful except in the particular scenario that we want to use rich to wrap text with color codes, which happens to be the situation that we're using rich in since #1693. This PR forces rich to supply codes by treating it as a terminal.

Unfortunately, I don't see how to test this automatically, but I was able to manually verify this with the following steps in WSL/Ubuntu from the jrnl source root:

poetry build
pipx uninstall jrnl
pipx install ./dist/jrnl-4.1b0-py3-none-any.whl
jrnl_log="$(jrnl -1 --format pretty)"
echo "$jrnl_log"

My default journal has colors configured, so once I got this working, the colors appeared in the terminal after running the above commands.

Checklist

  • I have read the contributing doc.
  • I have included a link to the relevant issue number.
  • I have checked to ensure there aren't other open pull requests
    for the same issue.
  • I have written new tests for these changes, as needed.

@micahellison micahellison marked this pull request as ready for review October 31, 2023 01:02
@micahellison micahellison merged commit cf14512 into jrnl-org:develop Oct 31, 2023
9 checks passed
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.

Update from 4.0.1_4 to 4.0.1_5 broke something with colors
1 participant