Skip to content

Instantly share code, notes, and snippets.

@remeniuk
Created May 6, 2012 17:12
Show Gist options
  • Save remeniuk/2623345 to your computer and use it in GitHub Desktop.
Save remeniuk/2623345 to your computer and use it in GitHub Desktop.
CLI in SBT
object DslRepl extends Build {
val host = SettingKey[String]("host", "The host that the REPL will connect to.")
val port = SettingKey[Int]("port", "The port that the REPL will connect to.")
lazy val root = Project("root", file(".")) settings (
libraryDependencies ++= Seq(
"com.vasilrem" % "somedsl" % "0.1"
),
host := "127.0.0.1",
port := 7777,
initialCommands in console <<= (host, port) {(h, p) => """
Thread.currentThread.setContextClassLoader(getClass.getClassLoader)
import com.vasilrem.somedsl.lang._
Context.init(%s, %s)
""".format(host, port)}
)
}
~/projects/somedsl: ./run.sh
import com.vasilrem.somedsl.lang._
Welcome to Scala version 2.9.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_26).
Type in expressions to have them evaluated.
Type :help for more information.
scala> call some_service and print to file "./file"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment