Skip to main content

Commands

clean

Clean the workspace.

Passed inputs will establish the Scala CLI project, for which the workspace will be cleaned.

For detailed documentation refer to our website: https://scala-cli.virtuslab.org/docs/commands/clean

Accepts option groups: bsp file, global suppress warning, logging, power, verbosity, workspace

compile

Compile Scala code.

Specific compile configurations can be specified with both command line options and using directives defined in sources. Command line options always take priority over using directives when a clash occurs, allowing to override configurations defined in sources. Using directives can be defined in all supported input source file types.

Multiple inputs can be passed at once. Paths to directories, URLs and supported file types are accepted as inputs. Accepted file extensions: .scala, .sc, .java, .jar, .md, .jar, .c, .h, .zip For piped inputs use the corresponding alias: _.scala, _.java, _.sc, _.md All supported types of inputs can be mixed with each other.

For detailed documentation refer to our website: https://scala-cli.virtuslab.org/docs/commands/compile

Accepts option groups: compilation server, compile, coursier, cross, debug, dependency, global suppress warning, help group, input, jvm, logging, markdown, power, python, Scala.js, Scala Native, scalac, scalac extra, semantic db, shared, snippet, source generator, suppress warning, verbosity, version, watch, workspace

config

Configure global settings for Scala CLI.

Syntax:

  scala-cli config key value

For example, to globally set the interactive mode:

  scala-cli config interactive true

Available keys:

  • actions Globally enables actionable diagnostics. Enabled by default.
  • github.token GitHub token.
  • httpProxy.address HTTP proxy address.
  • httpProxy.password HTTP proxy password (used for authentication).
  • httpProxy.user HTTP proxy user (used for authentication).
  • interactive Globally enables interactive mode (the '--interactive' flag).
  • interactive-was-suggested Setting indicating if the global interactive mode was already suggested.
  • java.properties Java properties for Scala CLI's execution.
  • pgp.public-key The PGP public key, used for signing.
  • pgp.secret-key The PGP secret key, used for signing.
  • pgp.secret-key-password The PGP secret key password, used for signing.
  • power Globally enables power mode (the '--power' launcher flag).
  • publish.credentials Publishing credentials, syntax: repositoryAddress value:user value:password [realm]
  • publish.user.email The 'email' user detail, used for publishing.
  • publish.user.name The 'name' user detail, used for publishing.
  • publish.user.url The 'url' user detail, used for publishing.
  • repositories.credentials Repository credentials, syntax: repositoryAddress value:user value:password [realm]
  • repositories.default Default repository, syntax: https://first-repo.company.com https://second-repo.company.com
  • repositories.mirrors Repository mirrors, syntax: repositories.mirrors maven:*=https://repository.company.com/maven
  • suppress-warning.directives-in-multiple-files Globally suppresses warnings about directives declared in multiple source files.
  • suppress-warning.experimental-features Globally suppresses warnings about experimental features.
  • suppress-warning.outdated-dependencies-files Globally suppresses warnings about outdated dependencies.

For detailed documentation refer to our website: https://scala-cli.virtuslab.org/docs/commands/config

Accepts option groups: config, coursier, debug, global suppress warning, jvm, logging, pgp scala signing, power, verbosity

dependency-update

Update dependency directives in the project

Accepts option groups: compilation server, coursier, debug, dependency, dependency update, global suppress warning, help group, input, jvm, logging, markdown, power, python, Scala.js, Scala Native, scalac, scalac extra, semantic db, shared, snippet, source generator, suppress warning, verbosity, version, workspace

doc

Generate Scaladoc documentation.

Multiple inputs can be passed at once. Paths to directories, URLs and supported file types are accepted as inputs. Accepted file extensions: .scala, .sc, .java, .jar, .md, .jar, .c, .h, .zip For piped inputs use the corresponding alias: _.scala, _.java, _.sc, _.md All supported types of inputs can be mixed with each other.

For detailed documentation refer to our website: https://scala-cli.virtuslab.org/docs/commands/doc

Accepts option groups: compilation server, coursier, debug, dependency, doc, global suppress warning, help group, input, jvm, logging, markdown, power, python, Scala.js, Scala Native, scalac, scalac extra, semantic db, shared, snippet, source generator, suppress warning, verbosity, version, workspace

export

Export current project to an external build tool (like SBT or Mill) or to JSON.

The whole Scala CLI project should get exported along with its dependencies configuration.

Unless otherwise configured, the default export format is SBT.

Multiple inputs can be passed at once. Paths to directories, URLs and supported file types are accepted as inputs. Accepted file extensions: .scala, .sc, .java, .jar, .md, .jar, .c, .h, .zip For piped inputs use the corresponding alias: _.scala, _.java, _.sc, _.md All supported types of inputs can be mixed with each other.

Detailed documentation can be found on our website: https://scala-cli.virtuslab.org

The export sub-command is experimental. Please bear in mind that non-ideal user experience should be expected. If you encounter any bugs or have feedback to share, make sure to reach out to the maintenance team at https://github.com/VirtusLab/scala-cli

Accepts option groups: compilation server, coursier, debug, dependency, export, global suppress warning, help group, input, jvm, logging, main class, markdown, power, python, Scala.js, Scala Native, scalac, scalac extra, semantic db, shared, snippet, source generator, suppress warning, verbosity, version, workspace

fix

Perform fixes on a Scala CLI project.

Specific fix configurations can be specified with both command line options and using directives defined in sources. Command line options always take priority over using directives when a clash occurs, allowing to override configurations defined in sources. Using directives can be defined in all supported input source file types.

Multiple inputs can be passed at once. Paths to directories, URLs and supported file types are accepted as inputs. Accepted file extensions: .scala, .sc, .java, .jar, .md, .jar, .c, .h, .zip For piped inputs use the corresponding alias: _.scala, _.java, _.sc, _.md All supported types of inputs can be mixed with each other.

For detailed documentation refer to our website: https://scala-cli.virtuslab.org/docs/commands/fix

The fix sub-command is experimental. Please bear in mind that non-ideal user experience should be expected. If you encounter any bugs or have feedback to share, make sure to reach out to the maintenance team at https://github.com/VirtusLab/scala-cli

Accepts option groups: compilation server, coursier, debug, dependency, global suppress warning, help group, input, jvm, logging, markdown, power, python, Scala.js, Scala Native, scalac, scalac extra, semantic db, shared, snippet, source generator, suppress warning, verbosity, version, workspace

fmt

Aliases: format, scalafmt

Formats Scala code.

scalafmt is used to perform the formatting under the hood.

The .scalafmt.conf configuration file is optional. Default configuration values will be assumed by Scala CLI.

All standard Scala CLI inputs are accepted, but only Scala sources will be formatted (.scala and .sc files).

For detailed documentation refer to our website: https://scala-cli.virtuslab.org/docs/commands/fmt

Accepts option groups: compilation server, coursier, debug, dependency, fmt, global suppress warning, help group, input, jvm, logging, markdown, power, python, Scala.js, Scala Native, scalac, scalac extra, semantic db, shared, snippet, source generator, suppress warning, verbosity, version, workspace

help

Print help message

Accepts option groups: global suppress warning, logging, power, verbosity

install completions

Aliases: install-completions

Installs Scala CLI completions into your shell

For detailed documentation refer to our website: https://scala-cli.virtuslab.org/docs/commands/completions

Accepts option groups: global suppress warning, install completions, logging, power, verbosity

new

New giter8 template.

Creates a new project from a giter8 template.

The new sub-command is experimental. Please bear in mind that non-ideal user experience should be expected. If you encounter any bugs or have feedback to share, make sure to reach out to the maintenance team at https://github.com/VirtusLab/scala-cli

Accepts option groups: global suppress warning, logging, power, verbosity

repl

Aliases: console

Fire-up a Scala REPL.

The entire Scala CLI project's classpath is loaded to the repl.

Specific repl configurations can be specified with both command line options and using directives defined in sources. Command line options always take priority over using directives when a clash occurs, allowing to override configurations defined in sources. Using directives can be defined in all supported input source file types.

Multiple inputs can be passed at once. Paths to directories, URLs and supported file types are accepted as inputs. Accepted file extensions: .scala, .sc, .java, .jar, .md, .jar, .c, .h, .zip For piped inputs use the corresponding alias: _.scala, _.java, _.sc, _.md All supported types of inputs can be mixed with each other.

For detailed documentation refer to our website: https://scala-cli.virtuslab.org/docs/commands/repl

Accepts option groups: compilation server, coursier, cross, debug, dependency, global suppress warning, help group, input, java, java prop, jvm, logging, markdown, power, python, repl, Scala.js, Scala Native, scalac, scalac extra, semantic db, shared, snippet, source generator, suppress warning, verbosity, version, watch, workspace

package

Compile and package Scala code.

Specific package configurations can be specified with both command line options and using directives defined in sources. Command line options always take priority over using directives when a clash occurs, allowing to override configurations defined in sources. Using directives can be defined in all supported input source file types.

Multiple inputs can be passed at once. Paths to directories, URLs and supported file types are accepted as inputs. Accepted file extensions: .scala, .sc, .java, .jar, .md, .jar, .c, .h, .zip For piped inputs use the corresponding alias: _.scala, _.java, _.sc, _.md All supported types of inputs can be mixed with each other.

For detailed documentation refer to our website: https://scala-cli.virtuslab.org/docs/commands/package

Accepts option groups: compilation server, coursier, cross, debug, dependency, global suppress warning, help group, input, java, java prop, jvm, logging, main class, markdown, package, packager, power, python, Scala.js, Scala Native, scalac, scalac extra, semantic db, shared, snippet, source generator, suppress warning, verbosity, version, watch, workspace

publish

Publishes build artifacts to Maven repositories.

We recommend running the publish setup sub-command once prior to running publish in order to set missing using directives for publishing. (but this is not mandatory) scala-cli --power publish setup .

Specific publish configurations can be specified with both command line options and using directives defined in sources. Command line options always take priority over using directives when a clash occurs, allowing to override configurations defined in sources. Using directives can be defined in all supported input source file types.

Multiple inputs can be passed at once. Paths to directories, URLs and supported file types are accepted as inputs. Accepted file extensions: .scala, .sc, .java, .jar, .md, .jar, .c, .h, .zip For piped inputs use the corresponding alias: _.scala, _.java, _.sc, _.md All supported types of inputs can be mixed with each other.

For detailed documentation refer to our website: https://scala-cli.virtuslab.org/docs/commands/publishing/publish

The publish sub-command is experimental. Please bear in mind that non-ideal user experience should be expected. If you encounter any bugs or have feedback to share, make sure to reach out to the maintenance team at https://github.com/VirtusLab/scala-cli

Accepts option groups: compilation server, coursier, cross, debug, dependency, global suppress warning, help group, input, jvm, logging, main class, markdown, pgp scala signing, power, publish, publish connection, publish params, publish repository, python, Scala.js, Scala Native, scalac, scalac extra, semantic db, shared, snippet, source generator, suppress warning, verbosity, version, watch, workspace

publish local

Publishes build artifacts to the local Ivy2 repository.

For detailed documentation refer to our website: https://scala-cli.virtuslab.org/docs/commands/publishing/publish-local

The publish-local sub-command is experimental. Please bear in mind that non-ideal user experience should be expected. If you encounter any bugs or have feedback to share, make sure to reach out to the maintenance team at https://github.com/VirtusLab/scala-cli

Accepts option groups: compilation server, coursier, cross, debug, dependency, global suppress warning, help group, input, jvm, logging, main class, markdown, pgp scala signing, power, publish, publish params, python, Scala.js, Scala Native, scalac, scalac extra, semantic db, shared, snippet, source generator, suppress warning, verbosity, version, watch, workspace

publish setup

Configures the project for publishing.

For detailed documentation refer to our website: https://scala-cli.virtuslab.org/docs/commands/publishing/publish-setup

The publish-setup sub-command is experimental. Please bear in mind that non-ideal user experience should be expected. If you encounter any bugs or have feedback to share, make sure to reach out to the maintenance team at https://github.com/VirtusLab/scala-cli

Accepts option groups: coursier, debug, global suppress warning, input, jvm, logging, pgp push pull, pgp scala signing, power, publish params, publish repository, publish setup, verbosity, version, workspace

run

Compile and run Scala code.

Specific run configurations can be specified with both command line options and using directives defined in sources. Command line options always take priority over using directives when a clash occurs, allowing to override configurations defined in sources. Using directives can be defined in all supported input source file types.

For a run to be successful, a main method must be present on the classpath. .sc scripts are an exception, as a main class is provided in their wrapper.

Multiple inputs can be passed at once. Paths to directories, URLs and supported file types are accepted as inputs. Accepted file extensions: .scala, .sc, .java, .jar, .md, .jar, .c, .h, .zip For piped inputs use the corresponding alias: _.scala, _.java, _.sc, _.md All supported types of inputs can be mixed with each other.

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

  scala-cli run Main.scala AnotherSource.scala -- first-arg second-arg

For detailed documentation refer to our website: https://scala-cli.virtuslab.org/docs/commands/run

Accepts option groups: benchmarking, compilation server, coursier, cross, debug, dependency, global suppress warning, help group, input, java, java prop, jvm, logging, main class, markdown, power, python, run, Scala.js, Scala Native, scalac, scalac extra, semantic db, shared, snippet, source generator, suppress warning, verbosity, version, watch, workspace

github secret create

Aliases: gh secret create

Creates or updates a GitHub repository secret.

  scala-cli --power github secret create --repo repo-org/repo-name SECRET_VALUE=value:secret

The secret-create sub-command is experimental. Please bear in mind that non-ideal user experience should be expected. If you encounter any bugs or have feedback to share, make sure to reach out to the maintenance team at https://github.com/VirtusLab/scala-cli

Accepts option groups: coursier, global suppress warning, logging, power, secret, secret create, verbosity

github secret list

Aliases: gh secret list

Lists secrets for a given GitHub repository.

The secret-list sub-command is experimental. Please bear in mind that non-ideal user experience should be expected. If you encounter any bugs or have feedback to share, make sure to reach out to the maintenance team at https://github.com/VirtusLab/scala-cli

Accepts option groups: global suppress warning, logging, power, secret, verbosity

setup-ide

Generates a BSP file that you can import into your IDE.

The setup-ide sub-command allows to pre-configure a Scala CLI project to import to an IDE with BSP support. It is also ran implicitly when compile, run, shebang or test sub-commands are called.

The pre-configuration should be saved in a BSP json connection file under the path:

    {project-root}/.bsp/scala-cli.json

Specific setup-ide configurations can be specified with both command line options and using directives defined in sources. Command line options always take priority over using directives when a clash occurs, allowing to override configurations defined in sources. Using directives can be defined in all supported input source file types.

For detailed documentation refer to our website: https://scala-cli.virtuslab.org/docs/commands/setup-ide

Accepts option groups: bsp file, compilation server, coursier, debug, dependency, global suppress warning, help group, input, jvm, logging, markdown, power, python, Scala.js, Scala Native, scalac, scalac extra, semantic db, setup IDE, shared, snippet, source generator, suppress warning, verbosity, version, workspace

shebang

Like run, but handier for shebang scripts.

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

When relying on the run sub-command, inputs and scala-cli options can be mixed, while program args have to be specified after --

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

However, for the shebang sub-command, only a single input file can be set, while all scala-cli options have to be set before the input file. All inputs after the first are treated as program arguments, without the need for --

  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")

For detailed documentation refer to our website: https://scala-cli.virtuslab.org/docs/commands/shebang

Accepts option groups: benchmarking, compilation server, coursier, cross, debug, dependency, global suppress warning, help group, input, java, java prop, jvm, logging, main class, markdown, power, python, run, Scala.js, Scala Native, scalac, scalac extra, semantic db, shared, snippet, source generator, suppress warning, verbosity, version, watch, workspace

test

Compile and test Scala code.

Test sources are compiled separately (after the 'main' sources), and may use different dependencies, compiler options, and other configurations. A source file is treated as a test source if:

  • the file name ends with .test.scala
  • the file comes from a directory that is provided as input, and the relative path from that file to its original directory contains a test directory
  • it contains the //> using target.scope "test" directive (Experimental)

Specific test configurations can be specified with both command line options and using directives defined in sources. Command line options always take priority over using directives when a clash occurs, allowing to override configurations defined in sources. Using directives can be defined in all supported input source file types.

Multiple inputs can be passed at once. Paths to directories, URLs and supported file types are accepted as inputs. Accepted file extensions: .scala, .sc, .java, .jar, .md, .jar, .c, .h, .zip For piped inputs use the corresponding alias: _.scala, _.java, _.sc, _.md All supported types of inputs can be mixed with each other.

For detailed documentation refer to our website: https://scala-cli.virtuslab.org/docs/commands/test

Accepts option groups: compilation server, coursier, cross, debug, dependency, global suppress warning, help group, input, java, java prop, jvm, logging, markdown, power, python, Scala.js, Scala Native, scalac, scalac extra, semantic db, shared, snippet, source generator, suppress warning, test, verbosity, version, watch, workspace

uninstall

Uninstalls Scala CLI. Works only when installed with the installation script. For detailed installation instructions refer to our website: https://scala-cli.virtuslab.org/install

Accepts option groups: compilation server, coursier, global suppress warning, logging, power, uninstall, uninstall completions, verbosity

uninstall completions

Aliases: uninstall-completions

Uninstalls Scala CLI completions from your shell.

For detailed documentation refer to our website: https://scala-cli.virtuslab.org/docs/commands/completions

Accepts option groups: global suppress warning, logging, power, uninstall completions, verbosity

update

Updates Scala CLI. Works only when installed with the installation script. If Scala CLI was installed with an external tool, refer to its update methods.

For detailed installation instructions refer to our website: https://scala-cli.virtuslab.org/install

Accepts option groups: global suppress warning, logging, power, update, verbosity

version

Prints the version of the Scala CLI and the default version of Scala. (which can be overridden in the project) If network connection is available, this sub-command also checks if the installed Scala CLI is up-to-date.

The version of the Scala CLI is the version of the command-line tool that runs Scala programs, which is distinct from the Scala version of the compiler. We recommend to specify the version of the Scala compiler for a project in its sources (via a using directive). Otherwise, Scala CLI falls back to the default Scala version defined by the runner.

For detailed documentation refer to our website: https://scala-cli.virtuslab.org/docs/commands/version

Accepts option groups: global suppress warning, logging, power, verbosity, version

Hidden commands

add-path

Add entries to the PATH environment variable.

Accepts option groups: add path, global suppress warning, logging, power, verbosity

bloop

Interact with Bloop (the build server) or check its status.

This sub-command allows to check the current status of Bloop. If Bloop isn't currently running, it will be started.

Bloop is the build server used by Scala CLI. For more information about Bloop, refer to https://scalacenter.github.io/bloop/

Accepts option groups: bloop, compilation server, coursier, debug, global suppress warning, jvm, logging, power, verbosity

bloop exit

Stop Bloop if an instance is running.

Bloop is the build server used by Scala CLI. For more information about Bloop, refer to https://scalacenter.github.io/bloop/

Accepts option groups: compilation server, coursier, global suppress warning, logging, power, verbosity

bloop output

Print Bloop output.

Bloop is the build server used by Scala CLI. For more information about Bloop, refer to https://scalacenter.github.io/bloop/

Accepts option groups: compilation server, global suppress warning, logging, power, verbosity

bloop start

Starts a Bloop instance, if none is running.

Bloop is the build server used by Scala CLI. For more information about Bloop, refer to https://scalacenter.github.io/bloop/

Accepts option groups: bloop start, compilation server, coursier, debug, global suppress warning, jvm, logging, power, verbosity

bsp

Start BSP server.

BSP stands for Build Server Protocol. For more information refer to https://build-server-protocol.github.io/

This sub-command is not designed to be used by a human. It is normally supposed to be invoked by your IDE when a Scala CLI project is imported.

Detailed documentation can be found on our website: https://scala-cli.virtuslab.org

Accepts option groups: bsp, compilation server, coursier, debug, dependency, global suppress warning, help group, input, jvm, logging, markdown, power, python, Scala.js, Scala Native, scalac, scalac extra, semantic db, shared, snippet, source generator, suppress warning, verbosity, version, workspace

default-file

Generates default files for a Scala CLI project (i.e. .gitignore).

For detailed documentation refer to our website: https://scala-cli.virtuslab.org/docs/commands/misc/default-file

Accepts option groups: default file, global suppress warning, logging, power, verbosity

directories

Prints directories used by Scala CLI.

Accepts option groups: global suppress warning, logging, power, verbosity

install-home

Install Scala CLI in a sub-directory of the home directory

Accepts option groups: global suppress warning, install home, logging, power, verbosity

pgp pull

Accepts option groups: global suppress warning, logging, pgp pull, pgp push pull, power, verbosity

pgp push

Accepts option groups: coursier, debug, global suppress warning, jvm, logging, pgp push, pgp push pull, pgp scala signing, power, verbosity

pgp create

Create PGP key pair

Accepts option groups: pgp create

pgp key-id

Accepts option groups: pgp key id

pgp sign

Sign files with PGP

Accepts option groups: pgp sign

pgp verify

Verify PGP signatures

Accepts option groups: pgp verify