Skip to content

Commit

Permalink
Merge pull request #59 from MoeOrganization/prakashk/repl-with-jline-1
Browse files Browse the repository at this point in the history
more useable REPL with jline 1.0
  • Loading branch information
Stevan Little committed Feb 22, 2013
2 parents d91a00c + 6ba13e9 commit 5f14183
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
11 changes: 11 additions & 0 deletions build.sbt
Expand Up @@ -9,3 +9,14 @@ scalacOptions ++= Seq("-deprecation", "-unchecked")
libraryDependencies += "org.scalatest" % "scalatest_2.10" % "1.9.1" % "test"

libraryDependencies += "commons-cli" % "commons-cli" % "1.2" % "compile"

libraryDependencies += "jline" % "jline" % "1.0"

// execute "run" task in a forked process
fork in run := true

// forward standard input to forked "run" process
connectInput in run := true

// send output to the build's standard output and error
outputStrategy := Some(StdoutOutput)
10 changes: 8 additions & 2 deletions src/main/scala/org/moe/Moe.scala
Expand Up @@ -121,12 +121,18 @@ object Moe {
*/
object REPL {
def enter (interpreter: Interpreter, runtime: MoeRuntime, dumpAST: Boolean = false): Unit = {
import jline.ConsoleReader

val cReader: ConsoleReader = new ConsoleReader
val prompt = "moe> "

while (true) {
val line = readLine("> ")
if (line != null && line != "exit") {
val line = cReader readLine prompt
if (line != null && line.length > 0 && line != "exit") {
evalLine(interpreter, runtime, line, dumpAST)
}
else {
if (line != "exit") println()
return
}
}
Expand Down

0 comments on commit 5f14183

Please sign in to comment.