From d44c9c55817839a41a7b4c509da027d7b4176ca5 Mon Sep 17 00:00:00 2001 From: Ben Burdette Date: Wed, 25 Mar 2020 11:20:44 -0600 Subject: [PATCH] some colors --- src/libutil/error.cc | 15 ++++++++++----- tests/errors/main.cc | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/libutil/error.cc b/src/libutil/error.cc index 4abee052d..9fbd234e0 100644 --- a/src/libutil/error.cc +++ b/src/libutil/error.cc @@ -62,7 +62,7 @@ void print_code_lines(string &prefix, NixCode &nix_code) arrows.append("^"); } - cout << format("%1% |%2%%3%") % prefix % spaces % arrows; + cout << format("%1% |%2%" ANSI_RED "%3%" ANSI_NORMAL) % prefix % spaces % arrows; } @@ -90,12 +90,16 @@ void print_error(ErrorInfo &einfo) { case ErrLevel::elError: { - level_string = "error:"; // TODO make red. + level_string = ANSI_RED; + level_string += "error:"; + level_string += ANSI_NORMAL; break; } case ErrLevel::elWarning: { - level_string = "warning:"; // TODO make yellow. + level_string = ANSI_YELLOW; + level_string += "warning:"; + level_string += ANSI_NORMAL; break; } default: @@ -113,7 +117,7 @@ void print_error(ErrorInfo &einfo) dashes.append("-"); // divider. - cout << format("%1%%2% %3% %4% %5% %6%") + cout << format("%1%%2%" ANSI_BLUE " %3% %4% %5% %6%" ANSI_NORMAL) % prefix % level_string % "---" @@ -131,7 +135,8 @@ void print_error(ErrorInfo &einfo) ? string(" ") + showErrLine(*einfo.nixCode->errLine) : ""; - cout << format("%1%in file: %2%%3%") % prefix % *einfo.nixCode->nixFile % eline << endl; + cout << format("%1%in file: " ANSI_BLUE "%2%%3%" ANSI_NORMAL) + % prefix % *einfo.nixCode->nixFile % eline << endl; cout << prefix << endl; } else diff --git a/tests/errors/main.cc b/tests/errors/main.cc index 5ac429b46..f53101629 100644 --- a/tests/errors/main.cc +++ b/tests/errors/main.cc @@ -59,7 +59,7 @@ using namespace nix; print_error(MkNixError() .name("error name") - .description("warning description") + .description("error description") .nixFile("myfile.nix") .lineNumber(40) .columnRange(13,7)