CLI Reference
The Turbo CLI provides everything you need: compilation, testing, formatting, REPL, and more.
Commands
| Command | Description |
|---|---|
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 install | Install dependencies from turbo.toml |
turbolang update | Update GitHub dependencies |
turbolang fmt <file.tb> | Format source code |
turbolang doc <file.tb> | Generate documentation |
turbolang repl | Interactive REPL |
turbolang lsp | Start Language Server Protocol server |
turbolang check <file.tb> | Type-check without compiling |
turbolang explain <code> | Explain an error code (e.g. E0100) |
turbolang playground | Launch 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.tbturbolang 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-appturbolang test
Runs all functions marked with @test:
$ turbolang test myfile.tb
PASS test_add
PASS test_subtract
2 passed, 0 failedturbolang 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.tbturbolang repl
Start an interactive read-eval-print loop for experimenting:
$ turbolang repl
turbo> print("hello")
hello
turbo> let x = 42
turbo> print(x * 2)
84turbolang 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 lspturbolang explain
Look up any compiler error code:
$ turbolang explain E0100
E0100: type mismatch
$ turbolang explain E0200
E0200: match expression is not exhaustiveBuilt-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 | sqrt, abs, pow, min, max |
| Async | spawn, channel, send, recv, mutex, mutex_get, mutex_set, sleep |
| Conversion | to_str, clone |