Use pager for more commands

This commit is contained in:
Eelco Dolstra 2014-08-20 21:26:37 +02:00
parent 9481f77693
commit 43579c9799
2 changed files with 8 additions and 1 deletions

View file

@ -977,6 +977,9 @@ static void opQuery(Globals & globals, Strings opFlags, Strings opArgs)
return; return;
} }
bool tty = isatty(STDOUT_FILENO);
RunPager pager;
Table table; Table table;
std::ostringstream dummy; std::ostringstream dummy;
XMLWriter xml(true, *(xmlOutput ? &cout : &dummy)); XMLWriter xml(true, *(xmlOutput ? &cout : &dummy));
@ -1049,7 +1052,7 @@ static void opQuery(Globals & globals, Strings opFlags, Strings opArgs)
} }
} else { } else {
string column = (string) "" + ch + " " + version; string column = (string) "" + ch + " " + version;
if (diff == cvGreater && isatty(STDOUT_FILENO)) if (diff == cvGreater && tty)
column = ANSI_RED + column + ANSI_NORMAL; column = ANSI_RED + column + ANSI_NORMAL;
columns.push_back(column); columns.push_back(column);
} }
@ -1240,6 +1243,8 @@ static void opListGenerations(Globals & globals, Strings opFlags, Strings opArgs
int curGen; int curGen;
Generations gens = findGenerations(globals.profile, curGen); Generations gens = findGenerations(globals.profile, curGen);
RunPager pager;
for (Generations::iterator i = gens.begin(); i != gens.end(); ++i) { for (Generations::iterator i = gens.begin(); i != gens.end(); ++i) {
tm t; tm t;
if (!localtime_r(&i->creationTime, &t)) throw Error("cannot convert time"); if (!localtime_r(&i->creationTime, &t)) throw Error("cannot convert time");

View file

@ -299,6 +299,8 @@ static void opQuery(Strings opFlags, Strings opArgs)
else if (*i == "--include-outputs") includeOutputs = true; else if (*i == "--include-outputs") includeOutputs = true;
else throw UsageError(format("unknown flag %1%") % *i); else throw UsageError(format("unknown flag %1%") % *i);
RunPager pager;
switch (query) { switch (query) {
case qOutputs: { case qOutputs: {