Skip to content

CLI Reference

The Turbo CLI provides everything you need: compilation, testing, formatting, REPL, and more.

Commands

CommandDescription
turbolang run <file.tb>Compile and run via JIT (Cranelift)
turbolang build <file.tb>Compile to a native binary (AOT)
turbolang test <file.tb>Run @test functions
turbolang bench <file.tb>Benchmark with timing
turbolang init <name>Create a new project
turbolang installInstall dependencies from turbo.toml
turbolang updateUpdate GitHub dependencies
turbolang search <query>Search the package registry index
turbolang fmt <file.tb>Format source code
turbolang doc <file.tb>Generate documentation
turbolang replInteractive REPL
turbo-lspStart Language Server Protocol server
turbolang check <file.tb>Type-check without compiling
turbolang explain <code>Explain an error code (e.g. E0100)
turbolang playgroundLaunch the local playground server

Playground

The hosted Turbo Playground lets you try syntax in a browser without installing anything. It uses a configured sandbox runner when hosted execution is available, and otherwise gives you a local run command. It does not execute arbitrary code in the website process.

Without a hosted sandbox, run the trusted local playground from your own machine:

$ turbolang playground
# opens http://localhost:8080

turbolang run

Compiles and executes a Turbo source file using the JIT compiler. Best for development.

$ turbolang run hello.tb
Hello, world!

# With verbose output
$ turbolang run --verbose hello.tb

turbolang build

Compiles to a standalone native binary. The binary is linked with the C runtime and has no external dependencies.

# Compile to a native binary
$ turbolang build hello.tb
$ ./hello

# With custom output name
$ turbolang build hello.tb --output my-app
$ ./my-app

turbolang test

Runs all functions marked with @test:

$ turbolang test myfile.tb
  PASS  test_add
  PASS  test_subtract
2 passed, 0 failed

turbolang fmt

Formats source code according to the standard Turbo style:

# Format a file in place
$ turbolang fmt myfile.tb

# Check formatting without modifying
$ turbolang fmt --check myfile.tb

turbolang repl

Start an interactive read-eval-print loop for experimenting:

$ turbolang repl
turbo> print("hello")
hello
turbo> let x = 42
turbo> print(x * 2)
84

turbo-lsp

Starts the Language Server Protocol server for editor integration. The legacy `turbolang lsp` subcommand remains available for older integrations. Provides:

  • Real-time diagnostics and error highlighting
  • Hover information for types and functions
  • Go-to-definition
  • Code completions
  • Document symbols
# Usually started automatically by your editor
$ turbo-lsp

turbolang explain

Look up any compiler error code:

$ turbolang explain E0100
E0100: type mismatch

$ turbolang explain E0200
E0200: match expression is not exhaustive

Built-in Functions

These functions are available globally without any imports:

CategoryFunctions
I/Oprint, assert, assert_eq, assert_ne
Stringslen, split, trim, upper, lower, replace, contains, starts_with, ends_with, join, repeat, to_str
Arrayslen, push, map, filter, reduce, sort
Hashmapstyped HashMap<K,V> (int/str keys, any value), hashmap, hashmap_set, hashmap_get, hashmap_has, hashmap_len, hashmap_keys, hashmap_remove
Database (SQLite)sqlite_open, sqlite_close, sqlite_exec, sqlite_error, sqlite_prepare, sqlite_bind_int, sqlite_bind_str, sqlite_bind_float, sqlite_step, sqlite_column_int, sqlite_column_str, sqlite_column_float, sqlite_column_count, sqlite_finalize
Mathsqrt, abs, pow, min, max
Asyncspawn, channel, send, recv, mutex, mutex_get, mutex_set, sleep
Conversionto_str, clone