Closed santagada closed 6 years ago
I really like to see color output, but I don't like the approach, by using code from some else. What I would like to see is a Class that add supports for streaming by using ANSI colors. Very simple and useful, and I think you can do it :)
Or using functions... print red("No packages installed") print green("Downloading %s…") % package_name print amber("Couldn't sync with remote repository!")
Or create a class that is a String with color support and be able to detect pipe redirections. (istty).
Remember from Library/Rudix.mk...
# # Functions # define info_color printf "\033[32m$1\033[0m\n" endef define warning_color printf "\033[33mWarning: $1\033[0m\n" endef define error_color printf "\033[31mError: $1\033[0m\n" endef
this is exactly what termcolor provides and it is only 100 lines for all colors/backgrouns and resets.
On Sun, Jun 1, 2014 at 10:49 PM, Rudá Moura notifications@github.com wrote:
Remember from Library/Rudix.mk...
#
Functions
# define info_color printf "\033[32m$1\033[0m\n" endef
define warning_color printf "\033[33mWarning: $1\033[0m\n" endef
define error_color printf "\033[31mError: $1\033[0m\n" endef
— Reply to this email directly or view it on GitHub https://github.com/rudix-mac/rudix/issues/47#issuecomment-44796207.
Leonardo Santagada
output from rudix command is not colored, but colors can help to make the output easier to parse by humans. The idea is to use termcolor[1] and somehow detect if it is running on a tty ("if sys.stdout.isatty():" should be enough) and if so print results using color.
[1] https://pypi.python.org/pypi/termcolor