mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-30 01:26:15 +02:00
format -> fmt
This commit is contained in:
parent
555baa8fb0
commit
8c2bf15c4f
1 changed files with 30 additions and 27 deletions
|
@ -11,9 +11,9 @@ std::optional<string> ErrorInfo::programName = std::nullopt;
|
||||||
string showErrPos(const ErrPos &errPos)
|
string showErrPos(const ErrPos &errPos)
|
||||||
{
|
{
|
||||||
if (errPos.column > 0) {
|
if (errPos.column > 0) {
|
||||||
return (format("(%1%:%2%)") % errPos.lineNumber % errPos.column).str();
|
return fmt("(%1%:%2%)", errPos.lineNumber, errPos.column);
|
||||||
} else {
|
} else {
|
||||||
return (format("(%1%)") % errPos.lineNumber).str();
|
return fmt("(%1%)", errPos.lineNumber);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,18 +21,18 @@ void printCodeLines(const string &prefix, const NixCode &nixCode)
|
||||||
{
|
{
|
||||||
// previous line of code.
|
// previous line of code.
|
||||||
if (nixCode.prevLineOfCode.has_value()) {
|
if (nixCode.prevLineOfCode.has_value()) {
|
||||||
std::cout << format("%1% %|2$5d|| %3%")
|
std::cout << fmt("%1% %|2$5d|| %3%",
|
||||||
% prefix
|
prefix,
|
||||||
% (nixCode.errPos.lineNumber - 1)
|
(nixCode.errPos.lineNumber - 1),
|
||||||
% *nixCode.prevLineOfCode
|
*nixCode.prevLineOfCode)
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// line of code containing the error.%2$+5d%
|
// line of code containing the error.%2$+5d%
|
||||||
std::cout << format("%1% %|2$5d|| %3%")
|
std::cout << fmt("%1% %|2$5d|| %3%",
|
||||||
% prefix
|
prefix,
|
||||||
% (nixCode.errPos.lineNumber)
|
(nixCode.errPos.lineNumber),
|
||||||
% nixCode.errLineOfCode
|
nixCode.errLineOfCode)
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
// error arrows for the column range.
|
// error arrows for the column range.
|
||||||
|
@ -45,15 +45,18 @@ void printCodeLines(const string &prefix, const NixCode &nixCode)
|
||||||
|
|
||||||
std::string arrows("^");
|
std::string arrows("^");
|
||||||
|
|
||||||
std::cout << format("%1% |%2%" ANSI_RED "%3%" ANSI_NORMAL) % prefix % spaces % arrows << std::endl;
|
std::cout << fmt("%1% |%2%" ANSI_RED "%3%" ANSI_NORMAL,
|
||||||
|
prefix,
|
||||||
|
spaces,
|
||||||
|
arrows) << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// next line of code.
|
// next line of code.
|
||||||
if (nixCode.nextLineOfCode.has_value()) {
|
if (nixCode.nextLineOfCode.has_value()) {
|
||||||
std::cout << format("%1% %|2$5d|| %3%")
|
std::cout << fmt("%1% %|2$5d|| %3%",
|
||||||
% prefix
|
prefix,
|
||||||
% (nixCode.errPos.lineNumber + 1)
|
(nixCode.errPos.lineNumber + 1),
|
||||||
% *nixCode.nextLineOfCode
|
*nixCode.nextLineOfCode)
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,7 +81,7 @@ void printErrorInfo(const ErrorInfo &einfo)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
levelString = (format("invalid error level: %1%") % einfo.level).str();
|
levelString = fmt("invalid error level: %1%", einfo.level);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,13 +94,13 @@ void printErrorInfo(const ErrorInfo &einfo)
|
||||||
dashes.append("-");
|
dashes.append("-");
|
||||||
|
|
||||||
// divider.
|
// divider.
|
||||||
std::cout << format("%1%%2%" ANSI_BLUE " %3% %4% %5% %6%" ANSI_NORMAL)
|
std::cout << fmt("%1%%2%" ANSI_BLUE " %3% %4% %5% %6%" ANSI_NORMAL,
|
||||||
% prefix
|
prefix,
|
||||||
% levelString
|
levelString,
|
||||||
% "---"
|
"---",
|
||||||
% einfo.name
|
einfo.name,
|
||||||
% dashes
|
dashes,
|
||||||
% einfo.programName.value_or("")
|
einfo.programName.value_or(""))
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
// filename.
|
// filename.
|
||||||
|
@ -107,11 +110,11 @@ void printErrorInfo(const ErrorInfo &einfo)
|
||||||
? string(" ") + showErrPos(einfo.nixCode->errPos)
|
? string(" ") + showErrPos(einfo.nixCode->errPos)
|
||||||
: "";
|
: "";
|
||||||
|
|
||||||
std::cout << format("%1%in file: " ANSI_BLUE "%2%%3%" ANSI_NORMAL)
|
std::cout << fmt("%1%in file: " ANSI_BLUE "%2%%3%" ANSI_NORMAL
|
||||||
% prefix % einfo.nixCode->errPos.nixFile % eline << std::endl;
|
, prefix, einfo.nixCode->errPos.nixFile, eline) << std::endl;
|
||||||
std::cout << prefix << std::endl;
|
std::cout << prefix << std::endl;
|
||||||
} else {
|
} else {
|
||||||
std::cout << format("%1%from command line argument") % prefix << std::endl;
|
std::cout << fmt("%1%from command line argument", prefix) << std::endl;
|
||||||
std::cout << prefix << std::endl;
|
std::cout << prefix << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue