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

Experimenting with colors.

This commit is contained in:
Cedric Beust 2015-12-12 10:22:33 -08:00
parent c9500e023a
commit b895d4c8f2
4 changed files with 20 additions and 3 deletions

View file

@ -1,2 +1 @@
#!/usr/bin/env bash
java -jar $(dirname $0)/kobalt/wrapper/kobalt-wrapper.jar $*

View file

@ -73,6 +73,23 @@ class AsciiArt {
val spaces = diff / 2 + 1
return fill(spaces) + s + fill(spaces + if (diff % 2 == 1) 1 else 0)
}
const val RESET = "\u001B[0m"
const val BLACK = "\u001B[30m"
const val RED = "\u001B[31m"
const val GREEN = "\u001B[32m"
const val YELLOW = "\u001B[33m";
const val BLUE = "\u001B[34m"
const val PURPLE = "\u001B[35m"
const val CYAN = "\u001B[36m"
const val WHITE = "\u001B[37m"
private fun wrap(s: String, color: String) = color + s + RESET
private fun red(s: String) = wrap(s, RED)
private fun yellow(s: String) = wrap(s, YELLOW)
fun taskColor(s: String) = yellow(s)
fun errorColor(s: String) = red(s)
}
}

View file

@ -303,7 +303,7 @@ class TaskWorker(val tasks: List<PluginTask>, val dryRun: Boolean) : IWorker<Plu
override fun call() : TaskResult2<PluginTask> {
if (tasks.size > 0) {
tasks[0].let {
log(1, AsciiArt.horizontalSingleLine + " ${it.project.name}:${it.name}")
log(1, AsciiArt.taskColor(AsciiArt.horizontalSingleLine + " ${it.project.name}:${it.name}"))
}
}
var success = true

View file

@ -1,5 +1,6 @@
package com.beust.kobalt.misc
import com.beust.kobalt.AsciiArt
import com.beust.kobalt.KobaltException
import com.beust.kobalt.api.Kobalt
import java.text.SimpleDateFormat
@ -66,7 +67,7 @@ class Logger(val dev: Boolean) {
val shortMessage = "***** E $text " + if (docUrl != null) " Documentation: $docUrl" else ""
val longMessage = "*****\n***** ERROR $text\n*****"
println(getPattern("E", shortMessage, longMessage, tag))
println(AsciiArt.errorColor(getPattern("E", shortMessage, longMessage, tag)))
if (KobaltLogger.LOG_LEVEL > 1) {
e?.printStackTrace()
}