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). Use --llvm for LLVM backend
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 fmt <file.tb>Format source code
turbolang doc <file.tb>Generate documentation
turbolang replInteractive REPL
turbolang 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 browser-based playground

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 native binary (Cranelift backend, default)
$ turbolang build hello.tb
$ ./hello

# Compile using the LLVM backend (requires LLVM 18)
$ turbolang build --llvm 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

turbolang lsp

Starts the Language Server Protocol server for editor integration. 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
$ turbolang 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
Hashmapshashmap, hashmap_set, hashmap_get, hashmap_has, hashmap_len, hashmap_keys, hashmap_remove
Mathsqrt, abs, pow, min, max
Asyncspawn, channel, send, recv, mutex, mutex_get, mutex_set, sleep
Conversionto_str, clone