diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2018-02-21 21:05:37 -0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2018-02-24 17:13:03 -0800 |
commit | c98408adf2d96928fe227a740631a8efd8e0c339 (patch) | |
tree | 5a36d9ee7d8ee6e1f7f9247cd7ddd31b194df5df /core/src | |
parent | 51db54d4f1deefb34b9d7f6581611ae166652493 (diff) | |
download | mill-c98408adf2d96928fe227a740631a8efd8e0c339.tar.gz mill-c98408adf2d96928fe227a740631a8efd8e0c339.tar.bz2 mill-c98408adf2d96928fe227a740631a8efd8e0c339.zip |
Clean up the provisional client-server code with unit tests and proper file-sockets
Seems to work well enough for interactive scala consoles, though still not Ammonite
Also Added ScalaModule#launcher and re-worked our build.sc file to use it
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/mill/eval/Evaluator.scala | 15 | ||||
-rw-r--r-- | core/src/mill/util/Logger.scala | 10 |
2 files changed, 18 insertions, 7 deletions
diff --git a/core/src/mill/eval/Evaluator.scala b/core/src/mill/eval/Evaluator.scala index 85dcf877..fd9d6bbe 100644 --- a/core/src/mill/eval/Evaluator.scala +++ b/core/src/mill/eval/Evaluator.scala @@ -286,21 +286,24 @@ case class Evaluator[T](outPath: Path, ) val out = System.out + val in = System.in val err = System.err try{ + System.setIn(multiLogger.inStream) System.setErr(multiLogger.errorStream) System.setOut(multiLogger.outputStream) - Console.withOut(multiLogger.outputStream){ - Console.withErr(multiLogger.errorStream){ - task.evaluate(args) + Console.withIn(multiLogger.inStream){ + Console.withOut(multiLogger.outputStream){ + Console.withErr(multiLogger.errorStream){ + task.evaluate(args) + } } } - }catch{ case NonFatal(e) => - - Result.Exception(e, new OuterStack(currentStack)) + }catch{ case NonFatal(e) => Result.Exception(e, new OuterStack(currentStack)) }finally{ System.setErr(err) System.setOut(out) + System.setIn(in) } } diff --git a/core/src/mill/util/Logger.scala b/core/src/mill/util/Logger.scala index 29cee23c..55ea84cc 100644 --- a/core/src/mill/util/Logger.scala +++ b/core/src/mill/util/Logger.scala @@ -29,6 +29,7 @@ trait Logger { def colored: Boolean val errorStream: PrintStream val outputStream: PrintStream + val inStream: InputStream def info(s: String): Unit def error(s: String): Unit def ticker(s: String): Unit @@ -39,6 +40,7 @@ object DummyLogger extends Logger { def colored = false object errorStream extends PrintStream(_ => ()) object outputStream extends PrintStream(_ => ()) + val inStream = new ByteArrayInputStream(Array()) def info(s: String) = () def error(s: String) = () def ticker(s: String) = () @@ -80,7 +82,8 @@ case class PrintLogger(colored: Boolean, colors: ammonite.util.Colors, outStream: PrintStream, infoStream: PrintStream, - errStream: PrintStream) extends Logger { + errStream: PrintStream, + inStream: InputStream) extends Logger { var printState: PrintState = PrintState.Newline @@ -133,6 +136,7 @@ case class FileLogger(colored: Boolean, file: Path) extends Logger { def info(s: String) = outputStream.println(s) def error(s: String) = outputStream.println(s) def ticker(s: String) = outputStream.println(s) + val inStream: InputStream = new ByteArrayInputStream(Array()) override def close() = { if (outputStreamUsed) outputStream.close() @@ -150,6 +154,10 @@ case class MultiLogger(colored: Boolean, streams: Logger*) extends Logger { override def flush() = streams.foreach(_.outputStream.flush()) override def close() = streams.foreach(_.outputStream.close()) } + lazy val inStream = streams.collect{case t: PrintLogger => t}.headOption match{ + case Some(x) => x.inStream + case None => new ByteArrayInputStream(Array()) + } def info(s: String) = streams.foreach(_.info(s)) def error(s: String) = streams.foreach(_.error(s)) |