Scala - Initialize REPL environment

亡梦爱人 提交于 2019-12-03 03:30:26

There is a github project called scala-ssh-shell which may do what you want, or at least get you closer.

-Hi, sorry I not Scala REPL hacker but i think you can do something like:

class YourILoop(in0: Option[BufferedReader], protected override val out: JPrintWriter)         
    extends ILoop(in0, out) {
    override def createInterpreter() {
       if (addedClasspath != "")
          settings.classpath append addedClasspath

          intp = new ILoopInterpreter
          val x = 3;
          intp.bind("x", x)
    }
}
object Run {
    def errorFn(str: String): Boolean = {
      Console.err println str
      false
    }

    def process(args: Array[String]): Boolean = {
        val command = new GenericRunnerCommand(args.toList, (x: String) => errorFn(x))
        import command.{ settings, howToRun, thingToRun }
        new YourILoop process settings
    }
    def main(args: Array[String]) {
        process(args)  
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!