FLiT
FLiT copied to clipboard
Bisect: color output
Feature Request
Describe the new feature: Now that the Makefiles output in color, it may be good to have the command-line tools to output in color as well, primarily FLiT Bisect
Suggested change:
Utilize python-pygments
as an optional dependency. If it is there, use it to output in color, otherwise, just do what we already do.
Alternative approaches: Do the output ourselves.
There are many options for doing color output from python
Many of these options are from this stackoverflow:
https://stackoverflow.com/questions/287871/how-to-print-colored-text-in-terminal-in-python#287944
I propose a mixed approach where any one of these, if they are available on the system, will work. Maybe not all of these since there are so many here. But the idea to be able to use python-pygments
and fall back on curses
, blessings
, colorama
, or even tput
or direct ANSII codes. It's something to investigate.
python-pygments
This package provides the pygmentize
tool and the pygments
python module. It is for syntax highlighting of source code and one of its outputs is to the terminal.
See my sandbox for an example of using this package to do custom color output:
https://github.com/mikebentley15/sandbox/blob/master/python/pygmentize/colorprint.py
curses
Allows for total terminal control from python. Maybe a bit overkill, but possible
blessings
http://pypi.python.org/pypi/blessings/
Similar to curses and is supposed to be better.
from blessings import Terminal
t = Terminal()
print t.red('This is red.')
print t.bold_bright_red_on_black('Bright red on black')
straight ANSII codes
We could do this, but it may not be portable
using tput
Our Makefile
is colored by calling tput
and capturing the color string into a string variable for later use. We could do the same thing from python.
termcolor
The termcolor
module for python makes it pretty easy to make colored output. It is the entire scope of the tool.
colorama
The colorama
module for python also tries to make it easy to print in colors and is supposed to work cross-platform, meaning it will even work on Windows!
clint
https://github.com/kennethreitz/clint
icolor
https://github.com/brianmhunt/icolor