Skip to main content

Commands

This document describes as scala-cli behaves if run as scala command. See more information in SIP-46

about

Print details about this application

Accepts option groups: about, logging, verbosity

clean

Clean the workspace

Accepts option groups: bsp file, directories, logging, verbosity, workspace

compile

Compile Scala code

Accepts option groups: compilation server, compile, coursier, cross, debug, dependency, directories, help group, input, jvm, logging, markdown, Scala.js, Scala Native, scalac, scalac extra, shared, snippet, verbosity, watch, workspace

dependency-update

Update dependencies in project

Accepts option groups: compilation server, coursier, debug, dependency, dependency update, directories, help group, input, jvm, logging, markdown, Scala.js, Scala Native, scalac, scalac extra, shared, snippet, verbosity, workspace

doc

Generate Scaladoc documentation

Accepts option groups: compilation server, coursier, debug, dependency, directories, doc, help group, input, jvm, logging, markdown, Scala.js, Scala Native, scalac, scalac extra, shared, snippet, verbosity, workspace

doctor

Print details about this application

Accepts option groups: doctor, logging, verbosity

fmt

Aliases: format, scalafmt

Format Scala code

Accepts option groups: compilation server, coursier, debug, dependency, directories, fmt, help group, input, jvm, logging, markdown, Scala.js, Scala Native, scalac, scalac extra, shared, snippet, verbosity, workspace

help

Print help message

Accepts option groups: logging, verbosity

install completions

Aliases: install-completions

Installs completions into your shell

Accepts option groups: directories, install completions, logging, verbosity

repl

Aliases: console

Fire-up a Scala REPL

Accepts option groups: compilation server, coursier, cross, debug, dependency, directories, help group, input, java, jvm, logging, markdown, python, repl, Scala.js, Scala Native, scalac, scalac extra, shared, snippet, verbosity, watch, workspace

run

Compile and run Scala code.

To pass arguments to the application, just add them after --, like:

scala-cli MyApp.scala -- first-arg second-arg

Accepts option groups: benchmarking, compilation server, coursier, cross, debug, dependency, directories, help group, input, java, jvm, logging, main class, markdown, python, run, Scala.js, Scala Native, scalac, scalac extra, shared, snippet, verbosity, watch, workspace

setup-ide

Generate a BSP file that you can import into your IDE

Accepts option groups: bsp file, compilation server, coursier, debug, dependency, directories, help group, input, jvm, logging, markdown, Scala.js, Scala Native, scalac, scalac extra, setup IDE, shared, snippet, verbosity, workspace

shebang

Like run, but more handy from shebang scripts

This command is equivalent to run, but it changes the way Scala CLI parses its command-line arguments in order to be compatible with shebang scripts.

Normally, inputs and scala-cli options can be mixed. Program have to be specified after --

scala-cli [command] [scala_cli_options | input]... -- [program_arguments]...

Contrary, for shebang command, only a single input file can be set, all scala-cli options have to be set before the input file, and program arguments after the input file

scala-cli shebang [scala_cli_options]... input [program_arguments]...

Using this, it is possible to conveniently set up Unix shebang scripts. For example:

#!/usr/bin/env -S scala-cli shebang --scala-version 2.13
println("Hello, world)

Accepts option groups: benchmarking, compilation server, coursier, cross, debug, dependency, directories, help group, input, java, jvm, logging, main class, markdown, python, run, Scala.js, Scala Native, scalac, scalac extra, shared, snippet, verbosity, watch, workspace

test

Compile and test Scala code

Accepts option groups: compilation server, coursier, cross, debug, dependency, directories, help group, input, java, jvm, logging, markdown, Scala.js, Scala Native, scalac, scalac extra, shared, snippet, test, verbosity, watch, workspace

uninstall

Uninstall scala-cli - only works when installed by the installation script

Accepts option groups: compilation server, coursier, directories, logging, uninstall, uninstall completions, verbosity

uninstall completions

Aliases: uninstall-completions

Uninstalls completions from your shell

Accepts option groups: logging, uninstall completions, verbosity

update

Update scala-cli - only works when installed by the installation script

Accepts option groups: logging, update, verbosity

version

Print version

Accepts option groups: logging, verbosity, version

Hidden commands

bsp

Start BSP server

Accepts option groups: bsp, compilation server, coursier, debug, dependency, directories, help group, input, jvm, logging, markdown, Scala.js, Scala Native, scalac, scalac extra, shared, snippet, verbosity, workspace