1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 08:27:12 -07:00

Format correctly.

This commit is contained in:
Cedric Beust 2017-04-09 00:40:17 -07:00
parent 6401a9d2af
commit ffd641310d

View file

@ -76,10 +76,15 @@ class BuildListeners : IBuildListener, IBuildReportContributor {
} }
// Calculate the longest short message so we can create a column long enough to contain it
val width = 12 + (projectInfos.values.map { it.shortMessage?.length ?: 0 }.maxBy { it } ?: 0)
fun col1(s: String) = String.format(" %1\$-30s", s) fun col1(s: String) = String.format(" %1\$-30s", s)
fun col2(s: String) = String.format(" %1\$-13s", s) fun col2(s: String) = String.format(" %1\$-${width}s", s)
fun col3(s: String) = String.format(" %1\$-8s", s) fun col3(s: String) = String.format(" %1\$-8s", s)
// Only print the build report if there is more than one project and at least one of them failed // Only print the build report if there is more than one project and at least one of them failed
if (timings.any()) { if (timings.any()) {
// if (timings.size > 1 && hasFailures) { // if (timings.size > 1 && hasFailures) {
@ -89,7 +94,7 @@ class BuildListeners : IBuildListener, IBuildReportContributor {
table.append(AsciiArt.logBox(listOf(line), AsciiArt.bottomLeft2, AsciiArt.bottomRight2, indent = 10) + "\n") table.append(AsciiArt.logBox(listOf(line), AsciiArt.bottomLeft2, AsciiArt.bottomRight2, indent = 10) + "\n")
projectStatuses.forEach { pair -> projectStatuses.forEach { pair ->
val projectName = pair.first.name val projectName = pair.first.name
val cl = listOf(col1(projectName), col2(pair.second.toString()), val cl = listOf(col1(projectName), col2(pair.second),
col3(formatMillisLeft(projectInfos[projectName]!!.durationMillis, 8))) col3(formatMillisLeft(projectInfos[projectName]!!.durationMillis, 8)))
.joinToString(AsciiArt.verticalBar) .joinToString(AsciiArt.verticalBar)
table.append(" " + AsciiArt.verticalBar + " " + cl + " " + AsciiArt.verticalBar + "\n") table.append(" " + AsciiArt.verticalBar + " " + cl + " " + AsciiArt.verticalBar + "\n")