@@ -19,24 +19,6 @@ class ConsoleInterface {
1919 def run (args : Array [String ],
2020 bootClasspathString : String ,
2121 classpathString : String ,
22- // TODO: initial commands needs to be run under some form of special
23- // "silent" mode in the REPL. I.e. the effects should be had without
24- // any visual output.
25- //
26- // To do this we can use the `run` interface to the `ReplDriver` and
27- // pass it a special instance of `ParseResult` like `Silently(res: ParseResult)`
28- // and then observe the effects without printing to `ReplDriver#out`
29- //
30- // This way, the REPL can offer feedback on invalid commands but
31- // still function without stringly logic.
32- //
33- // This same principle can be applied to `cleanupCommands` and
34- // `bindValues`
35- //
36- // Steps:
37- //
38- // 1. Introduce `case class Silent(res: ParseResult) extends ParseResult`
39- // 2. Perform all steps in `interpret` as usual without printing to `out`
4022 initialCommands : String ,
4123 cleanupCommands : String ,
4224 loader : ClassLoader ,
@@ -51,6 +33,14 @@ class ConsoleInterface {
5133 } ++
5234 Array (" -classpath" , classpathString)
5335
54- new ReplDriver (completeArgs, classLoader = Some (loader)).runUntilQuit()
36+ val driver = new ReplDriver (completeArgs, classLoader = Some (loader))
37+ val initState = driver.initState
38+ val s0 = (bindNames, bindValues).zipped.folLeft(initState) {
39+ case (state, (name, value)) => driver.bind(name, value)(state)
40+ }
41+ val s1 = driver.run(initialCommands)(s0)
42+ // handle failure during initialisation
43+ val s2 = driver.runUntilQuit(s1)
44+ driver.run(s1)
5545 }
5646}
0 commit comments