CLI Reference

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

Commands

CommandDescription
turbo run <file.tb>Compile and run via JIT (Cranelift)
turbo build <file.tb>Compile to a native binary (AOT)
turbo build --llvm <file.tb>Compile with LLVM optimizations
turbo test <file.tb>Run @test functions
turbo bench <file.tb>Benchmark with timing
turbo init <name>Create a new project
turbo installInstall dependencies from turbo.toml
turbo updateUpdate GitHub dependencies
turbo fmt <file.tb>Format source code
turbo doc <file.tb>Generate documentation
turbo replInteractive REPL
turbo lspStart Language Server Protocol server
turbo explain <code>Explain an error code (e.g. E0100)

turbo run

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

$ turbo run hello.tb
Hello, world!

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

turbo build

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

# Default (Cranelift backend)
$ turbo build hello.tb
$ ./hello

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

# With LLVM optimizations (requires LLVM 18)
$ turbo build --llvm hello.tb

turbo test

Runs all functions marked with @test:

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

turbo fmt

Formats source code according to the standard Turbo style:

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

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

turbo repl

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

$ turbo 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. 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

turbo explain

Look up any compiler error code:

$ turbo explain E0100
E0100: Type mismatch
  The compiler expected one type but found another.

$ turbo explain E0200
E0200: Match expression is not exhaustive
  Your match is missing one or more possible patterns.

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
Mathmath_sqrt, math_abs, math_pow, math_min, math_max, math_floor, math_ceil
Asyncspawn, channel, send, recv, mutex, mutex_get, mutex_set, sleep
Conversionto_str, clone