I can’t get the option to work; am i doing something wrong?
$ scala repl -S 3.6.4-RC1 --repl-init-script 'println("Hello")'
Unrecognized argument: --repl-init-script
To list all available options, run
scala repl --help
But it works inside the repl:
bjornr@bjornux:~$ scala repl -S 3.6.4-RC1
Welcome to Scala 3.6.4-RC1 (21.0.5, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
scala> :reset --repl-init-script:'println("Hello")'
Resetting REPL state with the following settings:
--repl-init-script:println("Hello")
Hello
scala>
It’s from “ouside” using the code from command line which is the important use case; so you can pass an import for instance…
$ scala repl -S 3.6.4-RC1
Downloading Scala 3.6.4-RC1 compiler
Downloading Scala 3.6.4-RC1 bridge
Welcome to Scala 3.6.4-RC1 (21.0.5, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
scala> println(util.Properties.versionString)
version 2.13.15
if I understand correctly, scala-cli recognizes certain options as being compiler/REPL options and doesn’t require the -O, but this is one it apparently doesn’t know yet, so the -O is necessary
@bjornregnell it’s a REPL flag, not a Scala CLI or compiler one.
You pass it to the launched app, so to the REPL in this case, so after --.
scala repl -S 3.6.4-RC1 -- --repl-init-script 'println("Hello")'
Hello
Welcome to Scala 3.6.4-RC1 (23.0.1, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
scala>