1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-22 18:50:08 +03:00

feature #1353: state is only colored when using a tty

This commit is contained in:
Javi Fontan 2012-09-18 18:22:56 +02:00
parent d9cf939ea3
commit 8337da960b

View File

@ -98,11 +98,15 @@ module CLIHelper
BAD_STATES=%w{fail err err}
def CLIHelper.color_state(stat)
case stat.strip
when *OK_STATES
ANSI_GREEN+stat+ANSI_RESET
when *BAD_STATES
ANSI_RED+stat+ANSI_RESET
if $stdout.tty?
case stat.strip
when *OK_STATES
ANSI_GREEN+stat+ANSI_RESET
when *BAD_STATES
ANSI_RED+stat+ANSI_RESET
else
stat
end
else
stat
end