forked from lix-project/lix
Merge changes I697f4f39,I9f25235d into main
* changes: doc-comment Fields for Activity and Result types mildly refactor the renderActivity if hell-chain
This commit is contained in:
commit
521e08cbde
|
@ -402,31 +402,59 @@ std::string ProgressBar::getStatus(State & state)
|
||||||
|
|
||||||
expected = std::max(expected, act.expected);
|
expected = std::max(expected, act.expected);
|
||||||
|
|
||||||
std::string s;
|
std::string rendered;
|
||||||
|
|
||||||
if (running || done || expected || failed) {
|
if (running || done || expected || failed) {
|
||||||
if (running)
|
if (running) {
|
||||||
if (expected != 0)
|
if (expected != 0) {
|
||||||
s = fmt(ANSI_BLUE + numberFmt + ANSI_NORMAL "/" ANSI_GREEN + numberFmt + ANSI_NORMAL "/" + numberFmt,
|
auto const runningPart = fmt(numberFmt, running / unit);
|
||||||
running / unit, done / unit, expected / unit);
|
auto const donePart = fmt(numberFmt, done / unit);
|
||||||
else
|
auto const expectedPart = fmt(numberFmt, expected / unit);
|
||||||
s = fmt(ANSI_BLUE + numberFmt + ANSI_NORMAL "/" ANSI_GREEN + numberFmt + ANSI_NORMAL,
|
rendered = fmt(
|
||||||
running / unit, done / unit);
|
ANSI_BLUE "%s" ANSI_NORMAL "/" ANSI_GREEN "%s" ANSI_NORMAL "/%s",
|
||||||
else if (expected != done)
|
runningPart,
|
||||||
if (expected != 0)
|
donePart,
|
||||||
s = fmt(ANSI_GREEN + numberFmt + ANSI_NORMAL "/" + numberFmt,
|
expectedPart
|
||||||
done / unit, expected / unit);
|
);
|
||||||
else
|
} else {
|
||||||
s = fmt(ANSI_GREEN + numberFmt + ANSI_NORMAL, done / unit);
|
auto const runningPart = fmt(numberFmt, running / unit);
|
||||||
else
|
auto const donePart = fmt(numberFmt, done / unit);
|
||||||
s = fmt(done ? ANSI_GREEN + numberFmt + ANSI_NORMAL : numberFmt, done / unit);
|
rendered = fmt(
|
||||||
s = fmt(itemFmt, s);
|
ANSI_BLUE "%s" ANSI_NORMAL "/" ANSI_GREEN "%s" ANSI_NORMAL,
|
||||||
|
runningPart,
|
||||||
|
donePart
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else if (expected != done) {
|
||||||
|
if (expected != 0) {
|
||||||
|
auto const donePart = fmt(numberFmt, done / unit);
|
||||||
|
auto const expectedPart = fmt(numberFmt, expected / unit);
|
||||||
|
rendered = fmt(
|
||||||
|
ANSI_GREEN "%s" ANSI_NORMAL "/%s",
|
||||||
|
donePart,
|
||||||
|
expectedPart
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
auto const donePart = fmt(numberFmt, done / unit);
|
||||||
|
rendered = fmt(ANSI_GREEN "%s" ANSI_NORMAL, donePart);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
auto const donePart = fmt(numberFmt, done / unit);
|
||||||
|
|
||||||
|
// We only color if `done` is non-zero.
|
||||||
|
if (done) {
|
||||||
|
rendered = concatStrings(ANSI_GREEN, donePart, ANSI_NORMAL);
|
||||||
|
} else {
|
||||||
|
rendered = donePart;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rendered = fmt(itemFmt, rendered);
|
||||||
|
|
||||||
if (failed)
|
if (failed)
|
||||||
s += fmt(" (" ANSI_RED "%d failed" ANSI_NORMAL ")", failed / unit);
|
rendered += fmt(" (" ANSI_RED "%d failed" ANSI_NORMAL ")", failed / unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
return s;
|
return rendered;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto showActivity = [&](ActivityType type, const std::string & itemFmt, const std::string & numberFmt = "%d", double unit = 1) {
|
auto showActivity = [&](ActivityType type, const std::string & itemFmt, const std::string & numberFmt = "%d", double unit = 1) {
|
||||||
|
|
|
@ -14,23 +14,71 @@ typedef enum {
|
||||||
actRealise = 102,
|
actRealise = 102,
|
||||||
actCopyPaths = 103,
|
actCopyPaths = 103,
|
||||||
actBuilds = 104,
|
actBuilds = 104,
|
||||||
|
|
||||||
|
/** Fields:
|
||||||
|
* 0: string: path to store derivation being built.
|
||||||
|
* 1: string: representing the machine this is being built on. Empty string if local machine.
|
||||||
|
* 2: int: curRound, not used anymore, always 1?
|
||||||
|
* 3: int: nrRounds, not used anymore always 1?
|
||||||
|
*/
|
||||||
actBuild = 105,
|
actBuild = 105,
|
||||||
actOptimiseStore = 106,
|
actOptimiseStore = 106,
|
||||||
actVerifyPaths = 107,
|
actVerifyPaths = 107,
|
||||||
|
|
||||||
|
/** Fields:
|
||||||
|
* 0: string: store path
|
||||||
|
* 1: string: substituter
|
||||||
|
*/
|
||||||
actSubstitute = 108,
|
actSubstitute = 108,
|
||||||
|
|
||||||
|
/** Fields:
|
||||||
|
* 0: string: store path
|
||||||
|
* 1: string: substituter
|
||||||
|
*/
|
||||||
actQueryPathInfo = 109,
|
actQueryPathInfo = 109,
|
||||||
|
|
||||||
|
/** Fields:
|
||||||
|
* 0: string: store path
|
||||||
|
*/
|
||||||
actPostBuildHook = 110,
|
actPostBuildHook = 110,
|
||||||
actBuildWaiting = 111,
|
actBuildWaiting = 111,
|
||||||
} ActivityType;
|
} ActivityType;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
/** Fields:
|
||||||
|
* 0: int: bytes linked
|
||||||
|
*/
|
||||||
resFileLinked = 100,
|
resFileLinked = 100,
|
||||||
|
|
||||||
|
/** Fields:
|
||||||
|
* 0: string: last line
|
||||||
|
*/
|
||||||
resBuildLogLine = 101,
|
resBuildLogLine = 101,
|
||||||
resUntrustedPath = 102,
|
resUntrustedPath = 102,
|
||||||
resCorruptedPath = 103,
|
resCorruptedPath = 103,
|
||||||
|
|
||||||
|
/** Fields:
|
||||||
|
* 0: string: phase name
|
||||||
|
*/
|
||||||
resSetPhase = 104,
|
resSetPhase = 104,
|
||||||
|
|
||||||
|
/** Fields:
|
||||||
|
* 0: int: done
|
||||||
|
* 1: int: expected
|
||||||
|
* 2: int: running
|
||||||
|
* 3: int: failed
|
||||||
|
*/
|
||||||
resProgress = 105,
|
resProgress = 105,
|
||||||
|
|
||||||
|
/** Fields:
|
||||||
|
* 0: int: ActivityType
|
||||||
|
* 1: int: expected
|
||||||
|
*/
|
||||||
resSetExpected = 106,
|
resSetExpected = 106,
|
||||||
|
|
||||||
|
/** Fields:
|
||||||
|
* 0: string: last line
|
||||||
|
*/
|
||||||
resPostBuildLogLine = 107,
|
resPostBuildLogLine = 107,
|
||||||
} ResultType;
|
} ResultType;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue