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

Bisect: color output #278

Open
mikebentley15 opened this issue Jul 10, 2019 · 1 comment
Open

Bisect: color output #278

mikebentley15 opened this issue Jul 10, 2019 · 1 comment
Labels
documentation Involves touching documentation python Involves touching python code tests Involves touching tests

Comments

@mikebentley15
Copy link
Collaborator

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.

@mikebentley15 mikebentley15 added documentation Involves touching documentation python Involves touching python code tests Involves touching tests labels Jul 10, 2019
@mikebentley15
Copy link
Collaborator Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Involves touching documentation python Involves touching python code tests Involves touching tests
Projects
None yet
Development

No branches or pull requests

1 participant