1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 06:31:14 +02:00

Add some color

This commit is contained in:
Eelco Dolstra 2014-08-20 16:01:16 +02:00
parent 392430b2c4
commit 373fad75e1
6 changed files with 56 additions and 52 deletions

View file

@ -847,13 +847,6 @@ static VersionDiff compareVersionAgainstSet(
}
static string colorString(const string & s)
{
if (!isatty(STDOUT_FILENO)) return s;
return "\e[1;31m" + s + "\e[0m";
}
static void queryJSON(Globals & globals, vector<DrvInfo> & elems)
{
JSONObject topObj(cout);
@ -1056,7 +1049,8 @@ static void opQuery(Globals & globals, Strings opFlags, Strings opArgs)
}
} else {
string column = (string) "" + ch + " " + version;
if (diff == cvGreater) column = colorString(column);
if (diff == cvGreater && isatty(STDOUT_FILENO))
column = ANSI_RED + column + ANSI_NORMAL;
columns.push_back(column);
}
}