From 759f39800bb80eaa297ea2532b1640959487ed9c Mon Sep 17 00:00:00 2001 From: Ben Burdette Date: Fri, 27 Mar 2020 10:55:09 -0600 Subject: [PATCH] remove util.hh from deps --- src/libutil/ansicolor.hh | 13 +++++++++++++ src/libutil/error.cc | 2 +- src/libutil/error.hh | 25 ++++++++++++++++--------- src/libutil/util.hh | 10 +--------- 4 files changed, 31 insertions(+), 19 deletions(-) create mode 100644 src/libutil/ansicolor.hh diff --git a/src/libutil/ansicolor.hh b/src/libutil/ansicolor.hh new file mode 100644 index 000000000..390bd4d17 --- /dev/null +++ b/src/libutil/ansicolor.hh @@ -0,0 +1,13 @@ +#pragma once + +namespace nix +{ + /* Some ANSI escape sequences. */ + #define ANSI_NORMAL "\e[0m" + #define ANSI_BOLD "\e[1m" + #define ANSI_FAINT "\e[2m" + #define ANSI_RED "\e[31;1m" + #define ANSI_GREEN "\e[32;1m" + #define ANSI_YELLOW "\e[33;1m" + #define ANSI_BLUE "\e[34;1m" +} diff --git a/src/libutil/error.cc b/src/libutil/error.cc index 9194539a5..c986affcc 100644 --- a/src/libutil/error.cc +++ b/src/libutil/error.cc @@ -104,7 +104,7 @@ void printErrorInfo(ErrorInfo &einfo) } default: { - levelString = format("invalid error level: %1%") % einfo.level; + levelString = (format("invalid error level: %1%") % einfo.level).str(); break; } } diff --git a/src/libutil/error.hh b/src/libutil/error.hh index f02d7288a..88980afb7 100644 --- a/src/libutil/error.hh +++ b/src/libutil/error.hh @@ -1,11 +1,13 @@ #pragma once -#include "util.hh" +#include "ansicolor.hh" #include #include #include #include +#include + using std::string; using std::optional; using boost::format; @@ -251,8 +253,14 @@ class AddHint : private T // -------------------------------------------------------- // error types -typedef AddName>> StandardError; -typedef AddName>> StandardWarning; +typedef AddName< + AddDescription< + AddHint< + EIError>>> StandardError; +typedef AddName< + AddDescription< + AddHint< + EIWarning>>> StandardWarning; typedef AddName< AddDescription< @@ -260,13 +268,16 @@ typedef AddName< AddLineNumber< AddColumnRange< AddLOC< - AddHint>>>>>> MkNixError; + AddHint< + EIError>>>>>>> MkNixError; typedef AddName< AddDescription< AddNixFile< AddLineNumber< AddColumnRange< - AddLOC>>>>> MkNixWarning; + AddLOC< + AddHint< + EIWarning>>>>>>> MkNixWarning; // -------------------------------------------------------- @@ -274,9 +285,5 @@ typedef AddName< void printErrorInfo(ErrorInfo &einfo); -string showErrLine(ErrLine &errLine); - -void printCodeLines(string &prefix, NixCode &nixCode); - } diff --git a/src/libutil/util.hh b/src/libutil/util.hh index 3bfebcd15..d69e29158 100644 --- a/src/libutil/util.hh +++ b/src/libutil/util.hh @@ -2,6 +2,7 @@ #include "types.hh" #include "logging.hh" +#include "ansicolor.hh" #include #include @@ -423,15 +424,6 @@ std::string shellEscape(const std::string & s); void ignoreException(); -/* Some ANSI escape sequences. */ -#define ANSI_NORMAL "\e[0m" -#define ANSI_BOLD "\e[1m" -#define ANSI_FAINT "\e[2m" -#define ANSI_RED "\e[31;1m" -#define ANSI_GREEN "\e[32;1m" -#define ANSI_YELLOW "\e[33;1m" -#define ANSI_BLUE "\e[34;1m" - /* Truncate a string to 'width' printable characters. If 'filterAll' is true, all ANSI escape sequences are filtered out. Otherwise,