News for hackers. Stuff that matters.
Re:Make Your Python CLI Tools Pop with Rich by TylerE on Thursday January 20, 2022 @09:04PM (#30018301)
Question: How horribly does the world break if you pipe the output to a file instead of stdout?
Re:Make Your Python CLI Tools Pop with Rich by varenc on Thursday January 20, 2022 @10:31PM (#30018801)
Not at all! Like many CLI tools, it turns off the formatting when it detects you're not outputting to a terminal.

Here's where it checks: https://github.com/Textualize/rich/blob/5a457bfbc662ab8701dc... (and I just tested to confirm it does indeed work)

Re:Make Your Python CLI Tools Pop with Rich by windexh8er on Thursday January 20, 2022 @09:32PM (#30018483)
Rich McGugan (author of Rich) talks about a lot of different design aspects of Rich on an episode of Talk Python [0] last October. I've used it in a few projects since then and for what I've been using it for the output is still easily consumable. Rich is a game changer for output in Python and it pairs nicely with CLI libs like Click. McGugan also is putting a lot of effort into Textual [1] which is fantastic for TUI apps.

[0] https://talkpython.fm/episodes/show/336/terminal-magic-with-... [1] https://github.com/Textualize/textual

Re:Make Your Python CLI Tools Pop with Rich by willm on Friday January 21, 2022 @02:41AM (#30020395)
*Will McGugan :)
Re:Make Your Python CLI Tools Pop with Rich by windexh8er on Friday January 21, 2022 @10:34AM (#30024920)
Oh man, fail on my part. Apologies Will! I think now's a great time for me to donate. ¯\_(ツ)_/¯

Edit: Tried to sponsor your linked Ko-fi from what's listed in the rich repo, but the link provided doesn't work and searching your name doesn't pull anything up. Sent you an email to find a better way.

Re:Make Your Python CLI Tools Pop with Rich by eyegor on Thursday January 20, 2022 @09:09PM (#30018335)
I would assume the lib authors accounted for this, it's pretty easy to check with sys.stdout.isatty(). If not you could alias it yourself.