-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add a setting/API to run a code snippet/script in the REPL on startup #21242
Labels
Comments
noti0na1
added a commit
that referenced
this issue
Jan 9, 2025
Partial fix #21242: Add REPL init script setting Test with flag at REPL startup: ```scala > ./bin/scalaQ --repl-init-script 'println("Hello from init script!"); val i = 2 * 2' [warning] MainGenericRunner class is deprecated since Scala 3.5.0, and Scala CLI features will not work. [warning] Please be sure to update to the Scala CLI launcher to use the new features. [warning] Check the Scala 3.5.0 release notes to troubleshoot your installation. Hello from init script! val i: Int = 4 Welcome to Scala 3.6.4-RC1-bin-SNAPSHOT-nonbootstrapped-git-5ea7c13 (17.0.12, Java OpenJDK 64-Bit Server VM). Type in expressions for evaluation. Or try :help. scala> ``` Test inside REPL: ```scala sbt:scala3> repl Welcome to Scala 3.6.4-RC1-bin-SNAPSHOT-nonbootstrapped-git-20e6f11 (17.0.12, Java OpenJDK 64-Bit Server VM). Type in expressions for evaluation. Or try :help. scala> :reset --repl-init-script:'println("Hello from init script!")' Resetting REPL state with the following settings: --repl-init-script:println("Hello from init script!") Hello from init script! scala> ``` scala-cli can use this flag to passing init code to REPL.
The second point will be implemented in a separate PR. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What needs to be done
We need a way to pass a code snippet or Scala source file that'd be run on REPL startup.
This is very similar to
Ammonite
REPL's (https://github.com/com-lihaoyi/Ammonite or--amm
passed to Scala CLI)-c
/--code
option.Why do we need this?
Requirements
I'd imagine we need:
-e
flag does outside of the REPLContext
Past discussions:
The text was updated successfully, but these errors were encountered: