Scala -i <filename>

What is the replacement for -i in Scala 3?

OK, let me rephrase that question. Where can I find the documentation for the Scala REPL command-line arguments? Maybe I need to brush up on my search skills, but I just can’t seem to find it.

In case anyone is wondering why I need this, let me explain. I have a script that preloads my Scalar class and a units definition file into the REPL to make it function as a calculator that is fully aware of all common physical units. This could be very useful for science and engineering students, not to mention scientists and engineers themselves.

The script is called “calculator”, and it looks like this:

#!/usr/bin/env bash
# provides a calculator with units in the Scala REPL
export CLASSPATH=~/scalar/physical-scalar.jar
scala -i ~/scalar/init.scala

where the init.scala file contains this:

import scalar_._, units_._, mathx_._

The “scala -i” apparently does not work in Scala 3.

Not one person here knows where to find the documentation for the Scala 3 REPL command-line arguments? I find that hard to believe.

I’ve tried to follow the REPL’s main handlig of args here dotty/Main.scala at master · lampepfl/dotty · GitHub via ReplDriver and it does not seem to have any args for doing what you want as far as I can tell.

But there is another way: You can run the Scala 3 repl from inside sbt and add the imports by adding this to your build.sbt

initialCommands in console := """
  import scalar_.*, units_.*, mathx_.*

and you can put your jar-file in lib

OK, thanks. One question: how do I start the REPL in sbt? (I can’t find it in sbt help.)

I wish they would restore the -i option. Why was it dropped?

Just run console (or consoleQuick which does only load your project’s dependencies, but does not compile and load your project).

I think most things that are missing from the REPL are not so much dropped as just not developed yet.