CLI Reference
The Turbo CLI provides everything you need: compilation, testing, formatting, REPL, and more.
Commands
| Command | Description |
|---|---|
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 install | Install dependencies from turbo.toml |
turbo update | Update GitHub dependencies |
turbo fmt <file.tb> | Format source code |
turbo doc <file.tb> | Generate documentation |
turbo repl | Interactive REPL |
turbo lsp | Start 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.tbturbo 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.tbturbo test
Runs all functions marked with @test:
$ turbo test myfile.tb
PASS test_add
PASS test_subtract
2 passed, 0 failedturbo 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.tbturbo repl
Start an interactive read-eval-print loop for experimenting:
$ turbo repl
turbo> print("hello")
hello
turbo> let x = 42
turbo> print(x * 2)
84turbo 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 lspturbo 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:
| Category | Functions |
|---|---|
| I/O | print, assert, assert_eq, assert_ne |
| Strings | len, split, trim, upper, lower, replace, contains, starts_with, ends_with, join, repeat, to_str |
| Arrays | len, push, map, filter, reduce, sort |
| Hashmaps | hashmap, hashmap_set, hashmap_get, hashmap_has, hashmap_len, hashmap_keys, hashmap_remove |
| Math | math_sqrt, math_abs, math_pow, math_min, math_max, math_floor, math_ceil |
| Async | spawn, channel, send, recv, mutex, mutex_get, mutex_set, sleep |
| Conversion | to_str, clone |