diff options
author | Felix Mulder <felix.mulder@gmail.com> | 2016-06-07 20:01:55 +0200 |
---|---|---|
committer | Felix Mulder <felix.mulder@gmail.com> | 2016-06-09 11:38:40 +0200 |
commit | 1f1b3577bb1f05a237282ab7682f8a8c7bf406d1 (patch) | |
tree | 7218c6cfb0e75d11fc9bf369d9d1d614b7549e8a /bridge/src | |
parent | 01463f7024513a979aeed802173364a524c9ff04 (diff) | |
download | dotty-1f1b3577bb1f05a237282ab7682f8a8c7bf406d1.tar.gz dotty-1f1b3577bb1f05a237282ab7682f8a8c7bf406d1.tar.bz2 dotty-1f1b3577bb1f05a237282ab7682f8a8c7bf406d1.zip |
Add console interface for sbt
Diffstat (limited to 'bridge/src')
-rw-r--r-- | bridge/src/main/scala/xsbt/ConsoleInterface.scala | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/bridge/src/main/scala/xsbt/ConsoleInterface.scala b/bridge/src/main/scala/xsbt/ConsoleInterface.scala new file mode 100644 index 000000000..1aec2a241 --- /dev/null +++ b/bridge/src/main/scala/xsbt/ConsoleInterface.scala @@ -0,0 +1,68 @@ +/* sbt -- Simple Build Tool + * Copyright 2008, 2009 Mark Harrah + */ +package xsbt + +import xsbti.Logger +import scala.tools.nsc.{ GenericRunnerCommand, Interpreter, InterpreterLoop, ObjectRunner, Settings } +import scala.tools.nsc.interpreter.InteractiveReader +import scala.tools.nsc.reporters.Reporter +import scala.tools.nsc.util.ClassPath + +import dotty.tools.dotc.repl.REPL +import dotty.tools.dotc.repl.REPL.Config + +class ConsoleInterface { + def commandArguments( + args: Array[String], + bootClasspathString: String, + classpathString: String, + log: Logger + ): Array[String] = args + + def run(args: Array[String], + bootClasspathString: String, + classpathString: String, + initialCommands: String, + cleanupCommands: String, + loader: ClassLoader, + bindNames: Array[String], + bindValues: Array[Any], + log: Logger + ): Unit = { + val completeArgs = + args :+ + "-bootclasspath" :+ bootClasspathString :+ + "-classpath" :+ classpathString + + println("Starting dotty interpreter...") + val repl = ConsoleInterface.customRepl( + initialCommands :: Nil, + cleanupCommands :: Nil, + bindNames zip bindValues + ) + repl.process(completeArgs) + } +} + +object ConsoleInterface { + def customConfig( + initCmds: List[String], + cleanupCmds: List[String], + boundVals: Array[(String, Any)] + ) = new Config { + override val initialCommands: List[String] = initCmds + override val cleanupCommands: List[String] = cleanupCmds + override val boundValues: Array[(String, Any)] = boundVals + } + + def customRepl(cfg: Config): REPL = new REPL { + override lazy val config = cfg + } + + def customRepl( + initCmds: List[String], + cleanupCmds: List[String], + boundVals: Array[(String, Any)] + ): REPL = customRepl(customConfig(initCmds, cleanupCmds, boundVals)) +} |