-
Notifications
You must be signed in to change notification settings - Fork 140
allow to run a snippet when invoking the REPL #1854
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
Comments
Okay, so However, as pointed out in #604 (comment), there is a workaround for Scala 3 in the So I believe you can achieve what you want like this: ▶ scala-cli --scala-snippet 'object ToExport { def hello: String = "Hello" }; export ToExport.*'
# Compiling project (Scala 3.2.2, JVM)
# Compiled project (Scala 3.2.2, JVM)
# Welcome to Scala 3.2.2 (17.0.5, Java OpenJDK 64-Bit Server VM).
# Type in expressions for evaluation. Or try :help.
scala> hello
# val res0: String = Hello Now, ▶ scala-cli repl --script-snippet 'println("Hello")'
Compiling project (Scala 3.2.2, JVM)
Compiled project (Scala 3.2.2, JVM)
Welcome to Scala 3.2.2 (17.0.5, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
scala> snippet_sc.main(Array.empty)
Hello |
Aha. Thanks. So I was not really understanding this from the docs... The use case of allowing things to be visible from your top-level package etc when firing up the repl is quite nice to have. Perhaps include ỳour nice workaround above in docs at least? But export does not work for packages, only objects... |
So if it's a feature and not a bug then the docs should be updated and eagerly looking forward to #604 :) |
--script-snippet
does not work for the repl
sub command
I wonder if the |
Version(s)
$ scala-cli version
Scala CLI version: 0.1.20
Scala version (default): 3.2.2
Describe the bug
Running a provided --script-snippet or --scala-snippet at the start of a repl session should work. (It works fine for run.)
To Reproduce
Nothing is printed above, but it works for run:
Expected behaviour
The repl session should start by interpreting the snippet.
Use case: This can be used to e.g. import my own things to a repl session:
The text was updated successfully, but these errors were encountered: