You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 with scala-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:
$ scala-cli repl . --scala-snippet "import reqt.*"Starting compilation server
Compiling project (Scala3.3.1, JVM (17))
[warn] ./.scala-build/reqT-solver_6554fc5f28-77219591e6/src_generated/main/scala-snippet.scala:1:1
[warn] Noclass, traitorobjectis defined in the compilation unit.
[warn] The incremental compiler cannot record the dependency information in such case.
[warn] Some errors like unused importreferringtoanon-existentclassmightnotbereported.
[warn] importreqt.*
[warn] ^^^^^^^^^^^^^
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:
Yes, a use case would be to have a file like this: for example
// this is imports.scala//>usingtoolkitdefault//>usingdeporg.apache.commons:commons-numbers-combinatorics:1.1//>usingdeporg.scala-lang.modules::scala-parallel-collections:1.0.4//>usingdeporg.scala-graph:graph-core_2.13:2.0.1// more dependencies if neededimportcollection.parallel.CollectionConverters.*importscala.util.boundary, boundary.breakimportorg.apache.commons.numbers.combinatorics.{BinomialCoefficient, Factorial}
importscalax.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:
Although maybe this is not possible due to REPL's own limitations?
How does scala-cli repl --toolkit default do it? When we use that, os.??? is available immediately.
How does scala-cli repl --toolkit default do it? When we use that, os.??? is available immediately.
If you invoke any API while prefixing the full package (as os.??? is the full package path), then no imports are necessary.
Although maybe this is not possible due to REPL's own limitations?
@spamegg1 AFAIK the REPL currently does not have the API to deliver this, as well as a couple of other requested features.
However, improving this situation actually is on the 2024 Roadmap for Scala 3. So things might change soon.
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: