Added colored text in terminal

This commit is contained in:
Pasha Bibko
2025-07-20 13:10:57 +01:00
parent c8975f0c20
commit 7768ba4522
4 changed files with 95 additions and 14 deletions

View File

@@ -6,20 +6,25 @@ int main(int argc, char** argv)
{
using namespace LXC;
//
Lexer::LexerContext context;
Lexer::Token exampleToken(context, 2);
//
// Reads the given file to a string //
Util::ReturnVal fileContents = Util::ReadFile("example/example.lx");
if (fileContents.Failed())
{
// Stores the error for easier access //
Util::FileReadError& err = fileContents.Error();
if (fileContents.Suceeded())
std::cout << fileContents.Result() << std::endl;
// Prints the error to the console //
Util::PrintAs<Util::Color::WHITE>("[LXC]");
Util::PrintAs<Util::Color::LIGHT_RED>(" Error: ");
else
std::cout << fileContents.Error().reason << " | " << fileContents.Error().path << std::endl;
std::cout
<< Util::FileReadError::ReasonStr(err.reason) << ' '
<< '[' << std::filesystem::absolute(err.path) << ']'
<< std::endl;
// Returns with default exit code //
return -1;
}
return 0;
}