Skip to content

v0.1.13

Compare
Choose a tag to compare
@lwronski lwronski released this 12 Sep 17:59
· 2019 commits to main since this release
2714573

Change the default sub-command to repl when no args are passed

We no longer default to the help sub-command when no arguments are passed. Starting with 0.1.13 running Scala CLI with no args will launch the repl.

$ scala-cli -S 3
Welcome to Scala 3.1.3 (17.0.3, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.

scala> 

When inputs are provided, Scala CLI defaults to the run sub-command, as before.

$ cat hello.sc
println("Hello World")
$ scala-cli hello.sc
Hello World

This change was added by @Gedochao in #1268

Marking the project's workspace root with the project.settings.scala file

Scala CLI now supports marking the workspace root directory with an optional configuration file: project.settings.scala. The workspace root determines where the .bsp and .scala-build directories will be saved (which mostly affects what path should be opened in your IDE to import the Scala CLI project through BSP).

The settings file is also the recommended input for your project's using directives. Otherwise, it functions similarly to other .scala sources.

$ cat project.settings.scala
//> using scala "2.13.4"
$ cat hello.sc
println(util.Properties.versionString)
$ scala-cli hello.sc .
version 2.13.4

To see how exactly is the root directory resolved, see this document

Added in #1260 by @wleczny

Scala CLI is now built with Scala 3.2.0

We now rely on Scala 3.2.0 as the default internal Scala version used to build the project.

This change was added by @lwronski in #1314

Add resources support for Scala Native

Scala CLI now allows embedding resources (by default) in a Scala Native binary with the --native flag.

$ cat resources/scala-native/foo.c 
int foo(int i) {
  return i + 42;
}
$ cat hello.scala 
//> using platform "native"
//> using resourceDir "resources"

import scalanative.unsafe.*

@extern
def foo(int: CInt): CInt = extern

@main def main =
  println(foo(3))
$ scala-cli hello.scala --native 
45

Added in #812 by @jchyb

Default to the run sub-command instead of repl when the -e, --execute-script, --execute-scala or --execute-java options are passed.

Even though we default to the repl sub-command when no arguments are passed to Scala CLI, an exception to that rule is when a snippet is passed with one of the following options: -e, --execute-script, --execute-scala or --execute-java. In that case, the passed snippets are treated as inputs to be executed and switch the default to the run sub-command.

$ scala-cli -e 'println("Hello")'
Hello

If you still want to pass a snippet to the repl, you can either pass the repl sub-command explicitly or use one of the following options, as before: --script-snippet, --scala-snippet or --java-snippet.

$ scala-cli --script-snippet 'println("Hello")'
Welcome to Scala 3.1.3 (17.0.2, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
                                                                                                                                                             
scala> snippet_sc.main(Array.empty)
Hello

This change was introduced to make the -e option backwards compatible with the scala command.

Added in #1313 by @Gedochao

Work in progress

Support for Markdown (experimental)

Scala CLI can now accept .md inputs and run/compile a snippet of Scala code inside the markdown. Markdown sources are ignored by default unless passed explicitly as inputs. You can also enable including non-explicit .md inputs by passing the --enable-markdown option.

Plain scala snippets are treated similarly to .sc scripts which can be run by scala-cli:

$ cat Example.md
This is a simple example of an `.md` file with a Scala snippet.

```scala
val message = "Hello from Markdown"
println(message)
```
scala-cli Example.md
Hello from Markdown

See this document for more details about the experimental Markdown support.

Added in #1268 by @Gedochao

Add --python option for the run sub-command (experimental)

The run sub-command can now run ScalaPy when the --python option is passed.

$ cat helloscalapy.sc
import py.SeqConverters
val len = py.Dynamic.global.len(List(0, 2, 3).toPythonProxy)
println(s"Length is $len")
$ scala-cli helloscalapy.sc --python -S 2.13
Length is 3

Added in #1295 by @alexarchambault

Other changes

Documentation

Fixes

Build and internal changes

Updates

New Contributors

Full Changelog: v0.1.12...v0.1.13