@@ -19,24 +19,6 @@ class ConsoleInterface {
19
19
def run (args : Array [String ],
20
20
bootClasspathString : String ,
21
21
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`
40
22
initialCommands : String ,
41
23
cleanupCommands : String ,
42
24
loader : ClassLoader ,
@@ -51,6 +33,14 @@ class ConsoleInterface {
51
33
} ++
52
34
Array (" -classpath" , classpathString)
53
35
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)
55
45
}
56
46
}
0 commit comments