Skip to content

Feature initImportREPL: allow initial imports to be automatically available in repl session  #2732

Closed
@bjornregnell

Description

@bjornregnell

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:

console / initialCommands := "import mypack.stuff.*, otherpack.morestuff.*"

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 (Scala 3.3.1, JVM (17))
[warn] ./.scala-build/reqT-solver_6554fc5f28-77219591e6/src_generated/main/scala-snippet.scala:1:1
[warn] No class, trait or object is defined in the compilation unit.
[warn] The incremental compiler cannot record the dependency information in such case.
[warn] Some errors like unused import referring to a non-existent class might not be reported.
[warn] import reqt.*
[warn] ^^^^^^^^^^^^^

Additional context

This has been discussed in both #604 and #2185 - the latter has a wider scope.

Metadata

Metadata

Assignees

No one assigned

    Labels

    REPLIssues tied with the repl sub-command.UXenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions