mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 00:17:11 -07:00
Better build reports.
This commit is contained in:
parent
8168d263e0
commit
c23007f82b
3 changed files with 43 additions and 24 deletions
|
@ -36,31 +36,42 @@ class AsciiArt {
|
|||
|
||||
val horizontalSingleLine = "\u2500\u2500\u2500\u2500\u2500"
|
||||
val horizontalDoubleLine = "\u2550\u2550\u2550\u2550\u2550"
|
||||
val verticalBar = "\u2551"
|
||||
|
||||
// fun horizontalLine(n: Int) = StringBuffer().apply {
|
||||
// repeat(n, { append("\u2500") })
|
||||
// }.toString()
|
||||
|
||||
fun box(strings: List<String>) : List<String> {
|
||||
val ul = "\u2554"
|
||||
val ur = "\u2557"
|
||||
val h = "\u2550"
|
||||
val v = "\u2551"
|
||||
val bl = "\u255a"
|
||||
val br = "\u255d"
|
||||
|
||||
fun r(n: Int, w: String) : String {
|
||||
with(StringBuffer()) {
|
||||
repeat(n, { append(w) })
|
||||
return toString()
|
||||
}
|
||||
// Repeat
|
||||
fun r(n: Int, w: String) : String {
|
||||
with(StringBuffer()) {
|
||||
repeat(n, { append(w) })
|
||||
return toString()
|
||||
}
|
||||
}
|
||||
|
||||
val h = "\u2550"
|
||||
val ul = "\u2554"
|
||||
val ur = "\u2557"
|
||||
val bottomLeft = "\u255a"
|
||||
val bottomRight = "\u255d"
|
||||
|
||||
// Bottom left with continuation
|
||||
val bottomLeft2 = "\u2560"
|
||||
// Bottom right with continuation
|
||||
val bottomRight2 = "\u2563"
|
||||
|
||||
fun upperBox(max: Int) = ul + r(max + 2, h) + ur
|
||||
fun lowerBox(max: Int, bl: String = bottomLeft, br : String = bottomRight) = bl + r(max + 2, h) + br
|
||||
|
||||
private fun box(strings: List<String>, bl: String = bottomLeft, br: String = bottomRight) : List<String> {
|
||||
val v = verticalBar
|
||||
|
||||
val maxString: String = strings.maxBy { it.length } ?: ""
|
||||
val max = maxString.length
|
||||
val result = arrayListOf(ul + r(max + 2, h) + ur)
|
||||
val result = arrayListOf(upperBox(max))
|
||||
result.addAll(strings.map { "$v ${center(it, max - 2)} $v" })
|
||||
result.add(bl + r(max + 2, h) + br)
|
||||
result.add(lowerBox(max, bl, br))
|
||||
return result
|
||||
}
|
||||
|
||||
|
@ -68,14 +79,15 @@ class AsciiArt {
|
|||
|
||||
val defaultLog : (s: String) -> Unit = { log(1, " $it") }
|
||||
|
||||
fun logBox(strings: List<String>, print: (String) -> Unit = defaultLog) {
|
||||
box(strings).forEach {
|
||||
fun logBox(strings: List<String>, bl: String = bottomLeft, br: String = bottomRight,
|
||||
print: (String) -> Unit = defaultLog) {
|
||||
box(strings, bl, br).forEach {
|
||||
print(it)
|
||||
}
|
||||
}
|
||||
|
||||
fun logBox(s: String, print: (String) -> Unit = defaultLog) {
|
||||
logBox(listOf(s), print)
|
||||
fun logBox(s: String, bl: String = bottomLeft, br: String = bottomRight, print: (String) -> Unit = defaultLog) {
|
||||
logBox(listOf(s), bl, br, print)
|
||||
}
|
||||
|
||||
fun center(s: String, width: Int) : String {
|
||||
|
|
|
@ -42,7 +42,7 @@ class ResolveDependency @Inject constructor(
|
|||
val seen = hashSetOf(dep.id)
|
||||
root.addChildren(findChildren(root, seen))
|
||||
|
||||
AsciiArt.logBox(listOf(dep.id, url, dep.jarFile.get()).map { " $it" }, {s -> println(s) })
|
||||
AsciiArt.logBox(listOf(dep.id, url, dep.jarFile.get()).map { " $it" }, print = {s -> println(s) })
|
||||
|
||||
display(root.children)
|
||||
println("")
|
||||
|
|
|
@ -35,12 +35,19 @@ class BuildListeners : IBuildListener, IBuildReportContributor {
|
|||
}
|
||||
log(1, "\n")
|
||||
|
||||
log(1, "\n" + AsciiArt.horizontalSingleLine + " Build status")
|
||||
projectStatuses.forEach { pair ->
|
||||
log(1, " " + pair.first.name + " " + pair.second)
|
||||
}
|
||||
}
|
||||
|
||||
fun col1(s: String) = String.format(" %1\$-30s", s)
|
||||
fun col2(s: String) = String.format(" %1\$-10s", s)
|
||||
|
||||
val line = listOf(col1("Project"), col2("Build status")).joinToString(AsciiArt.verticalBar)
|
||||
AsciiArt.logBox(listOf(line), AsciiArt.bottomLeft2, AsciiArt.bottomRight2)
|
||||
projectStatuses.forEach { pair ->
|
||||
val cl = listOf(col1(pair.first.name), col2(pair.second.toString())).joinToString(AsciiArt.verticalBar)
|
||||
log(1, " " + AsciiArt.verticalBar + " " + cl + " " + AsciiArt.verticalBar)
|
||||
}
|
||||
log(1, " " + AsciiArt.lowerBox(line.length))
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue