@@ -26,6 +26,8 @@ import org.jline.reader._
2626
2727import scala .annotation .tailrec
2828import scala .collection .JavaConverters ._
29+ import scala .runtime .ZippedTraversable2
30+
2931
3032/** The state of the REPL contains necessary bindings instead of having to have
3133 * mutation
@@ -95,13 +97,15 @@ class ReplDriver(settings: Array[String],
9597 // is called, we're in business
9698 resetToInitial()
9799
100+ final def runUntilQuit (): State = runUntilQuit(initState)
101+
98102 /** Run REPL with `state` until `:quit` command found
99103 *
100104 * This method is the main entry point into the REPL. Its effects are not
101105 * observable outside of the CLI, for this reason, most helper methods are
102106 * `protected final` to facilitate testing.
103107 */
104- final def runUntilQuit (): State = {
108+ final def runUntilQuit (initialState : State ): State = {
105109 val terminal = new JLineTerminal ()
106110
107111 /** Blockingly read a line, getting back a parse result */
@@ -127,7 +131,7 @@ class ReplDriver(settings: Array[String],
127131 else loop(interpret(res)(state))
128132 }
129133
130- try withRedirectedOutput { loop(initState ) }
134+ try withRedirectedOutput { loop(initialState ) }
131135 finally terminal.close()
132136 }
133137
@@ -136,8 +140,14 @@ class ReplDriver(settings: Array[String],
136140 interpret(parsed)
137141 }
138142
143+ final def bindValues (bindPairs : ZippedTraversable2 [String , Any ]): State = {
144+ bindPairs.foldLeft(initState) {
145+ case (state, (name, value)) => bind(name, value)(state)
146+ }
147+ }
148+
139149 // TODO: i3007
140- final def bind (name: String , value: Any )(implicit state : State ): State = state
150+ private def bind (name: String , value: Any )(implicit state : State ): State = state
141151
142152 private def withRedirectedOutput (op : => State ): State =
143153 Console .withOut(out) { Console .withErr(out) { op } }
0 commit comments