-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature initImportREPL: allow initial imports to be automatically available in repl session #2732
Comments
Yes, a use case would be to have a file like this: for example // this is imports.scala
//> using toolkit default
//> using dep org.apache.commons:commons-numbers-combinatorics:1.1
//> using dep org.scala-lang.modules::scala-parallel-collections:1.0.4
//> using dep org.scala-graph:graph-core_2.13:2.0.1
// more dependencies if needed
import collection.parallel.CollectionConverters.*
import scala.util.boundary, boundary.break
import org.apache.commons.numbers.combinatorics.{BinomialCoefficient, Factorial}
import scalax.collection.generic.AbstractDiEdge
// more imports if needed then to start the repl with: $ scala-cli repl imports.scala and have the imports accessible in the REPL, for example: scala> BinomialCoefficient.value(10, 2)
val res0: Long = 45 Although maybe this is not possible due to REPL's own limitations? |
If you invoke any API while prefixing the full package (as
@spamegg1 AFAIK the REPL currently does not have the API to deliver this, as well as a couple of other requested features. |
See also discussion here: https://users.scala-lang.org/t/load-a-file-on-startup-into-scala-3-repl/9943 |
Many thanks for your work on making the REPL even nicer!!! |
Is your feature request related to a problem? Please describe.
It is tedious and annoying to have to retype
import allthethings.*
everytime I start the repl withscala-cli --repl .
Describe the solution you'd like
I would like a way to state what initial imports I want to directly access in all repl sessions of the current build. It should be able to do this both with a using-directive and a command-line option.
Describe alternatives you've considered
A more general solution is to provide the corresponding feature of sbt's
console / initialCommands
which would be more powerful. In sbt you write for example:I have tried using the scala-cli option
--scala-snippet
but that does not work with scala-cli version 1.1.2 as it gives this warning and ignores the import:Additional context
This has been discussed in both #604 and #2185 - the latter has a wider scope.
The text was updated successfully, but these errors were encountered: