2010-07-17 18:07:41 +02:00
|
|
|
/* sbt -- Simple Build Tool
|
2010-09-04 14:16:22 +02:00
|
|
|
* Copyright 2008, 2009, 2010 Mark Harrah
|
2010-07-17 18:07:41 +02:00
|
|
|
*/
|
2010-09-04 14:16:22 +02:00
|
|
|
package sbt
|
2010-07-17 18:07:41 +02:00
|
|
|
|
2011-04-09 01:15:13 +02:00
|
|
|
import java.io.File
|
|
|
|
|
import compiler.AnalyzingCompiler
|
2010-07-17 18:07:41 +02:00
|
|
|
|
2010-09-23 15:21:39 +02:00
|
|
|
final class Console(compiler: AnalyzingCompiler)
|
2010-07-17 18:07:41 +02:00
|
|
|
{
|
|
|
|
|
/** Starts an interactive scala interpreter session with the given classpath.*/
|
2010-09-04 14:16:22 +02:00
|
|
|
def apply(classpath: Seq[File], log: Logger): Option[String] =
|
2010-07-17 18:07:41 +02:00
|
|
|
apply(classpath, Nil, "", log)
|
|
|
|
|
|
2010-09-04 14:16:22 +02:00
|
|
|
def apply(classpath: Seq[File], options: Seq[String], initialCommands: String, log: Logger): Option[String] =
|
|
|
|
|
apply(classpath, options, initialCommands)(None, Nil)(log)
|
|
|
|
|
|
|
|
|
|
def apply(classpath: Seq[File], options: Seq[String], loader: ClassLoader, initialCommands: String)(bindings: (String, Any)*)(implicit log: Logger): Option[String] =
|
|
|
|
|
apply(classpath, options, initialCommands)(Some(loader), bindings)
|
|
|
|
|
|
|
|
|
|
def apply(classpath: Seq[File], options: Seq[String], initialCommands: String)(loader: Option[ClassLoader], bindings: Seq[(String, Any)])(implicit log: Logger): Option[String] =
|
2010-07-17 18:07:41 +02:00
|
|
|
{
|
2010-09-04 14:16:22 +02:00
|
|
|
def console0 = compiler.console(classpath, options, initialCommands, log)(loader, bindings)
|
2010-07-17 18:07:41 +02:00
|
|
|
JLine.withJLine( Run.executeTrapExit(console0, log) )
|
|
|
|
|
}
|
2010-09-04 14:16:22 +02:00
|
|
|
}
|
|
|
|
|
object Console
|
|
|
|
|
{
|
2011-03-05 14:25:17 +01:00
|
|
|
def apply(conf: Compiler.Inputs): Console = new Console( conf.compilers.scalac )
|
2010-09-04 14:16:22 +02:00
|
|
|
}
|