X-Git-Url: https://git.distorted.org.uk/~mdw/tripe-android/blobdiff_plain/04a5abaece151705e9bd7026653f79938a7a2fbc..HEAD:/terminal.scala?ds=sidebyside diff --git a/terminal.scala b/terminal.scala index 9722e2b..2e66aa2 100644 --- a/terminal.scala +++ b/terminal.scala @@ -32,6 +32,7 @@ import java.lang.Math.ceil; import java.lang.System.{currentTimeMillis, out => stdout}; import sys.isatty; +import Implicits.truish; /*----- Main code ---------------------------------------------------------*/ @@ -78,7 +79,7 @@ object TerminalEyecandy extends Eyecandy { def clear() { note(""); } def commit() { - if (last != "") { + if (last) { if (eyecandyp) stdout.write('\n'); else stdout.println(last); last = ""; @@ -98,7 +99,7 @@ object TerminalEyecandy extends Eyecandy { extends progress.JobReporter { private final val width = 40; private final val spinner = """/-\|"""; - private final val mingap = 100; + private final val mingap = 50; private[this] var step: Int = 0; private[this] var sweep: Int = 0; private[this] val t0 = currentTimeMillis; @@ -114,7 +115,7 @@ object TerminalEyecandy extends Eyecandy { val max = model.max; val sb = new StringBuilder; - sb ++= model.what; sb += ' '; + sb ++= model.what; sb += ':'; sb += ' '; /* Step the spinner. */ sb += spinner(step); sb += ' '; @@ -140,14 +141,14 @@ object TerminalEyecandy extends Eyecandy { sb += ']'; /* Quantitative progress. */ - val f = model.format(cur); if (f != "") { sb += ' '; sb ++= f; } + val f = model.format(cur); if (f) { sb += ' '; sb ++= f; } if (max > 0) sb ++= (100*cur/max).formatted(" %3d%%"); /* Estimated time to completion. */ val eta = model.eta(cur); if (eta >= 0) { sb += ' '; sb += '('; - sb ++= formatTime(ceil(eta/1000.0).toInt); + sb ++= formatDuration(ceil(eta/1000.0).toInt); sb += ')'; } @@ -156,12 +157,12 @@ object TerminalEyecandy extends Eyecandy { } def done() { - val t = formatTime(ceil((currentTimeMillis - t0)/1000.0).toInt); - record(s"${model.what} done ($t)"); + val t = formatDuration(ceil((currentTimeMillis - t0)/1000.0).toInt); + record(s"${model.what}: done ($t)"); } def failed(e: Exception) - { record(s"${model.what} FAILED: ${e.getMessage}"); } + { record(s"${model.what}: FAILED: ${e.getMessage}"); } step(0); }