Commit 0677702
authored
Partial fix #21242: Add REPL init script setting
Test with flag at REPL startup:
```scala
> ./bin/scalaQ --repl-init-script 'println("Hello from init script!"); val i = 2 * 2'
[warning] MainGenericRunner class is deprecated since Scala 3.5.0, and Scala CLI features will not work.
[warning] Please be sure to update to the Scala CLI launcher to use the new features.
[warning] Check the Scala 3.5.0 release notes to troubleshoot your installation.
Hello from init script!
val i: Int = 4
Welcome to Scala 3.6.4-RC1-bin-SNAPSHOT-nonbootstrapped-git-5ea7c13 (17.0.12, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
scala>
```
Test inside REPL:
```scala
sbt:scala3> repl
Welcome to Scala 3.6.4-RC1-bin-SNAPSHOT-nonbootstrapped-git-20e6f11 (17.0.12, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
scala> :reset --repl-init-script:'println("Hello from init script!")'
Resetting REPL state with the following settings:
--repl-init-script:println("Hello from init script!")
Hello from init script!
scala>
```
scala-cli can use this flag to passing init code to REPL.
File tree
3 files changed
+12
-1
lines changed- compiler
- src/dotty/tools
- dotc/config
- repl
- test-resources/repl
3 files changed
+12
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
| 129 | + | |
129 | 130 | | |
130 | 131 | | |
131 | 132 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
119 | | - | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
120 | 125 | | |
121 | 126 | | |
122 | 127 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
0 commit comments