cool-RR / PySnooper

Never use print for debugging again
MIT License
16.31k stars 954 forks source link

[feature request] Add command line color output for Windows #229

Open skjerns opened 1 year ago

skjerns commented 1 year ago

As requested in #1 , it would be nice to have colored output also for Windows, which should be possible, even though not as easily as in unix.

I don't think I can currently implement it (as I'm also not using PySnooper very often).

cool-RR commented 1 year ago

Cool, we'll wait for someone to volunteer to implement it. Note that it should be implemented without adding dependencies, so if we're using e.g. colorama, we'll need to copy-paste some of their code.

cool-RR commented 1 year ago

If I remember correctly, the reason I didn't implement this when I implemented the same feature for Linux is that there are multiple shells you can run in Windows. (CMD, MSYS bash, Powershell, whatever Windows 10 has going on for running Linux.) I may have tried a solution on a couple of these and got inconsistent results. So figuring out a solution that works for all of these (or at least degrades gracefully) is the main difficulty here.

cool-RR commented 1 year ago

The biggest priority in this feature is that whatever happens, we don't want to send an output with ugly shell escapes to a shell that won't interpret them correctly. That's the main disaster I'm trying to prevent.

SonGokussj4 commented 1 year ago

Just found out about PySnooper and it's a lovely library. I'm on Windows (Windows Terminal) and it's a shape it doesn't have colors. If you want to have some compatibility between shells, what about additional library like colorama or something like that? Second idea is to have colors.conf and let the user specify possible changes?

cool-RR commented 1 year ago

Thank you. My second message in this thread answers part of your message. In any case, if you want to implement this, go ahead.

SonGokussj4 commented 1 year ago

Oh I apologize. I've skimmed through from 1st to 3rd and 4th message.

I see the code where you specify the colors. Will try to experiment a little bit. It's not my strong topic thought :-) Anyway, have a great day.

P.S. Wouldn't it be possible to have something like like pip install pysnooper[colorama] which would be optional dependency or something like that? And then user can specify in pysnooper.conf if to use colorama or native shell escapes?

cool-RR commented 1 year ago

P.S. Wouldn't it be possible to have something like like pip install pysnooper[colorama] which would be optional dependency or something like that? And then user can specify in pysnooper.conf if to use colorama or native shell escapes?

It would be possible, but it means that for the rest of PySnooper's life I will have to confirm that these two branches work with each new release. The less moving parts, the less maintenace work I have to do.