remove util.hh from deps

This commit is contained in:
Ben Burdette 2020-03-27 10:55:09 -06:00
parent 00eb3fcb7a
commit 759f39800b
4 changed files with 31 additions and 19 deletions

13
src/libutil/ansicolor.hh Normal file
View file

@ -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"
}

View file

@ -104,7 +104,7 @@ void printErrorInfo(ErrorInfo &einfo)
} }
default: default:
{ {
levelString = format("invalid error level: %1%") % einfo.level; levelString = (format("invalid error level: %1%") % einfo.level).str();
break; break;
} }
} }

View file

@ -1,11 +1,13 @@
#pragma once #pragma once
#include "util.hh" #include "ansicolor.hh"
#include <string> #include <string>
#include <optional> #include <optional>
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include <boost/format.hpp>
using std::string; using std::string;
using std::optional; using std::optional;
using boost::format; using boost::format;
@ -251,8 +253,14 @@ class AddHint : private T
// -------------------------------------------------------- // --------------------------------------------------------
// error types // error types
typedef AddName<AddDescription<AddHint<EIError>>> StandardError; typedef AddName<
typedef AddName<AddDescription<AddHint<EIWarning>>> StandardWarning; AddDescription<
AddHint<
EIError>>> StandardError;
typedef AddName<
AddDescription<
AddHint<
EIWarning>>> StandardWarning;
typedef AddName< typedef AddName<
AddDescription< AddDescription<
@ -260,13 +268,16 @@ typedef AddName<
AddLineNumber< AddLineNumber<
AddColumnRange< AddColumnRange<
AddLOC< AddLOC<
AddHint<EIError>>>>>>> MkNixError; AddHint<
EIError>>>>>>> MkNixError;
typedef AddName< typedef AddName<
AddDescription< AddDescription<
AddNixFile< AddNixFile<
AddLineNumber< AddLineNumber<
AddColumnRange< AddColumnRange<
AddLOC<EIWarning>>>>>> MkNixWarning; AddLOC<
AddHint<
EIWarning>>>>>>> MkNixWarning;
// -------------------------------------------------------- // --------------------------------------------------------
@ -274,9 +285,5 @@ typedef AddName<
void printErrorInfo(ErrorInfo &einfo); void printErrorInfo(ErrorInfo &einfo);
string showErrLine(ErrLine &errLine);
void printCodeLines(string &prefix, NixCode &nixCode);
} }

View file

@ -2,6 +2,7 @@
#include "types.hh" #include "types.hh"
#include "logging.hh" #include "logging.hh"
#include "ansicolor.hh"
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -423,15 +424,6 @@ std::string shellEscape(const std::string & s);
void ignoreException(); 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' /* Truncate a string to 'width' printable characters. If 'filterAll'
is true, all ANSI escape sequences are filtered out. Otherwise, is true, all ANSI escape sequences are filtered out. Otherwise,