rudix-mac / rudix

Build system target on macOS with precompiled packages
https://rudix.org
BSD 3-Clause "New" or "Revised" License
194 stars 35 forks source link

Color results in rudix package manager #47

Closed santagada closed 6 years ago

santagada commented 10 years ago

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

ruda commented 10 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).

ruda commented 10 years ago

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
santagada commented 10 years ago

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