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) |
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 search <query> | Search the package registry index |
turbolang fmt <file.tb> | Format source code |
turbolang doc <file.tb> | Generate documentation |
turbolang repl | Interactive REPL |
turbo-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 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:8080turbolang 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 a native binary
$ turbolang build 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)
84turbo-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-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 | typed 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 |
| Math | sqrt, abs, pow, min, max |
| Async | spawn, channel, send, recv, mutex, mutex_get, mutex_set, sleep |
| Conversion | to_str, clone |