2021-06-26 15:24:07 +02:00
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
2019-11-20 07:51:21 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2019 Gwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>
|
|
|
|
|
*/
|
|
|
|
|
|
2020-07-11 07:56:11 +02:00
|
|
|
#include <unistd.h>
|
|
|
|
|
|
2019-11-20 07:51:21 +01:00
|
|
|
#include <iostream>
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
#include "display.hpp"
|
|
|
|
|
|
|
|
|
|
#define KNRM "\x1B[0m"
|
|
|
|
|
#define KRED "\x1B[31m"
|
|
|
|
|
#define KGRN "\x1B[32m"
|
|
|
|
|
#define KYEL "\x1B[33m"
|
|
|
|
|
#define KBLU "\x1B[34m"
|
|
|
|
|
#define KMAG "\x1B[35m"
|
|
|
|
|
#define KCYN "\x1B[36m"
|
|
|
|
|
#define KWHT "\x1B[37m"
|
|
|
|
|
|
|
|
|
|
void printError(std::string err, bool eol)
|
|
|
|
|
{
|
2020-07-11 07:56:11 +02:00
|
|
|
if (isatty(STDERR_FILENO))
|
|
|
|
|
std::cerr << KRED << err << "\e[0m";
|
|
|
|
|
else
|
|
|
|
|
std::cerr << err;
|
|
|
|
|
std::cerr << std::flush;
|
2019-11-20 07:51:21 +01:00
|
|
|
if (eol)
|
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-28 07:22:24 +01:00
|
|
|
void printWarn(std::string warn, bool eol)
|
|
|
|
|
{
|
|
|
|
|
if (isatty(STDOUT_FILENO))
|
|
|
|
|
std::cout << KYEL << warn << "\e[0m" << std::flush;
|
|
|
|
|
else
|
|
|
|
|
std::cout << warn;
|
|
|
|
|
std::cout << std::flush;
|
|
|
|
|
if (eol)
|
|
|
|
|
std::cout << std::endl;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-20 07:51:21 +01:00
|
|
|
void printInfo(std::string info, bool eol)
|
|
|
|
|
{
|
2020-07-11 07:56:11 +02:00
|
|
|
if (isatty(STDOUT_FILENO))
|
|
|
|
|
std::cout << KBLU << info << "\e[0m" << std::flush;
|
|
|
|
|
else
|
|
|
|
|
std::cout << info;
|
|
|
|
|
std::cout << std::flush;
|
2019-11-20 07:51:21 +01:00
|
|
|
if (eol)
|
|
|
|
|
std::cout << std::endl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void printSuccess(std::string success, bool eol)
|
|
|
|
|
{
|
2020-07-11 07:56:11 +02:00
|
|
|
if (isatty(STDOUT_FILENO))
|
|
|
|
|
std::cout << KGRN << success << "\e[0m" << std::flush;
|
|
|
|
|
else
|
|
|
|
|
std::cout << success;
|
|
|
|
|
std::cout << std::flush;
|
2019-11-20 07:51:21 +01:00
|
|
|
if (eol)
|
|
|
|
|
std::cout << std::endl;
|
|
|
|
|
}
|