mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2025-01-19 17:46:46 +02:00
treewide: shouldANSI() -> isTTY()
This commit is contained in:
parent
d9fc4bf5c5
commit
8c1eeb4681
8 changed files with 8 additions and 8 deletions
|
@ -50,7 +50,7 @@ std::string renderMarkdownToTerminal(std::string_view markdown)
|
||||||
if (!rndr_res)
|
if (!rndr_res)
|
||||||
throw Error("allocation error while rendering Markdown");
|
throw Error("allocation error while rendering Markdown");
|
||||||
|
|
||||||
return filterANSIEscapes(std::string(buf->data, buf->size), !shouldANSI());
|
return filterANSIEscapes(std::string(buf->data, buf->size), !isTTY());
|
||||||
#else
|
#else
|
||||||
return std::string(markdown);
|
return std::string(markdown);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -537,7 +537,7 @@ public:
|
||||||
|
|
||||||
Logger * makeProgressBar()
|
Logger * makeProgressBar()
|
||||||
{
|
{
|
||||||
return new ProgressBar(shouldANSI());
|
return new ProgressBar(isTTY());
|
||||||
}
|
}
|
||||||
|
|
||||||
void startProgressBar()
|
void startProgressBar()
|
||||||
|
|
|
@ -52,7 +52,7 @@ public:
|
||||||
: printBuildLogs(printBuildLogs)
|
: printBuildLogs(printBuildLogs)
|
||||||
{
|
{
|
||||||
systemd = getEnv("IN_SYSTEMD") == "1";
|
systemd = getEnv("IN_SYSTEMD") == "1";
|
||||||
tty = shouldANSI();
|
tty = isTTY();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isVerbose() override {
|
bool isVerbose() override {
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
bool shouldANSI()
|
bool isTTY()
|
||||||
{
|
{
|
||||||
return isatty(STDERR_FILENO)
|
return isatty(STDERR_FILENO)
|
||||||
&& getEnv("TERM").value_or("dumb") != "dumb"
|
&& getEnv("TERM").value_or("dumb") != "dumb"
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace nix {
|
||||||
* Determine whether ANSI escape sequences are appropriate for the
|
* Determine whether ANSI escape sequences are appropriate for the
|
||||||
* present output.
|
* present output.
|
||||||
*/
|
*/
|
||||||
bool shouldANSI();
|
bool isTTY();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Truncate a string to 'width' printable characters. If 'filterAll'
|
* Truncate a string to 'width' printable characters. If 'filterAll'
|
||||||
|
|
|
@ -1090,7 +1090,7 @@ static void opQuery(Globals & globals, Strings opFlags, Strings opArgs)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tty = shouldANSI();
|
bool tty = isTTY();
|
||||||
RunPager pager;
|
RunPager pager;
|
||||||
|
|
||||||
Table table;
|
Table table;
|
||||||
|
|
|
@ -378,7 +378,7 @@ void mainWrapped(int argc, char * * argv)
|
||||||
settings.verboseBuild = false;
|
settings.verboseBuild = false;
|
||||||
|
|
||||||
// If on a terminal, progress will be displayed via progress bars etc. (thus verbosity=notice)
|
// If on a terminal, progress will be displayed via progress bars etc. (thus verbosity=notice)
|
||||||
if (nix::shouldANSI()) {
|
if (nix::isTTY()) {
|
||||||
verbosity = lvlNotice;
|
verbosity = lvlNotice;
|
||||||
} else {
|
} else {
|
||||||
verbosity = lvlInfo;
|
verbosity = lvlInfo;
|
||||||
|
|
|
@ -189,7 +189,7 @@ static int main_nix_prefetch_url(int argc, char * * argv)
|
||||||
|
|
||||||
Finally f([]() { stopProgressBar(); });
|
Finally f([]() { stopProgressBar(); });
|
||||||
|
|
||||||
if (shouldANSI())
|
if (isTTY())
|
||||||
startProgressBar();
|
startProgressBar();
|
||||||
|
|
||||||
auto store = openStore();
|
auto store = openStore();
|
||||||
|
|
Loading…
Reference in a new issue