CLI Reference
Complete reference for all TinyLang CLI commands, options, and flags.
Usage
tinylang <command> [options] [arguments]
If no command is provided, the REPL starts automatically.
run
Execute a TinyLang source file using the tree-walk interpreter.
tinylang run <file.tiny>
Examples
tinylang run main.tiny
tinylang run examples/07-fibonacci.tiny
You can also run a file directly: tinylang main.tiny (the run command is implied for .tiny files).
compile
Compile a source file to TinyLang bytecode (.tinyc).
tinylang compile <file.tiny> [options]
Options
| Flag | Short | Description |
|---|---|---|
--output <path> | -o | Output file path (default: same name with .tinyc extension) |
--no-optimize | Skip bytecode optimization pass | |
--disassemble | -d | Print disassembly to stdout |
Examples
# Compile with default output
tinylang compile app.tiny
# Creates: app.tinyc
# Custom output path
tinylang compile app.tiny -o build/app.tinyc
# View disassembly
tinylang compile app.tiny --disassemble
# Skip optimization
tinylang compile app.tiny --no-optimize
Output
Compiled: 24 instructions, 5 constants, optimized 3 bytes
Output: app.tinyc (128 bytes)
exec
Execute a compiled bytecode file on the virtual machine.
tinylang exec <file.tinyc>
Examples
tinylang exec app.tinyc
tinylang exec build/program.tinyc
You can also run .tinyc files directly: tinylang app.tinyc
debug
Start the interactive debugger for step-through execution.
tinylang debug <file.tiny>
Debugger Commands
| Command | Short | Description |
|---|---|---|
step | s | Step to the next statement |
step_into | si | Step into a function call |
step_out | so | Step out of the current function |
continue | c | Continue to next breakpoint |
break <line> | b | Set a breakpoint at a line |
locals | l | Show local variables |
eval <expr> | e | Evaluate an expression |
help | h | Show help text |
quit | q | Exit the debugger |
Example Session
$ tinylang debug examples/03-functions.tiny
TinyLang Debugger
File: examples/03-functions.tiny
-> 1 fn add(a, b) {
debug> b 5
Breakpoint set at line 5
debug> c
debug> locals
a = 3
b = 4
debug> eval a + b
7
debug> quit
fmt
Format TinyLang source files with consistent style.
Every result is re-parsed and compared against the AST it was produced from. If anything
differs, the command reports the difference and exits 1 without writing, so --write
cannot replace a file with code that means something else.
tinylang fmt <file.tiny> [files...] [options]
Options
| Flag | Short | Description |
|---|---|---|
--write | -w | Write formatted output back to file |
--check | Check mode - exit 1 if changes would be made |
Examples
# Preview formatted output (stdout)
tinylang fmt main.tiny
# Write changes to files
tinylang fmt --write main.tiny lib.tiny
# Check if files are formatted (CI mode)
tinylang fmt --check src/*.tiny
lint
Run static analysis to find potential issues.
tinylang lint <file.tiny> [files...] [options]
Options
| Flag | Description |
|---|---|
--fix | Automatically fix issues where possible |
Lint Rules
| Rule | Default | Description |
|---|---|---|
prefer-const | warning | Use const when variable is never reassigned |
no-unused-variables | warning | Variables declared but never used |
no-empty-blocks | warning | Empty function or loop bodies |
unreachable-code | error | Code after return or break |
no-shadow | info | Variable shadowing in nested scopes |
Examples
# Check for issues
tinylang lint main.tiny
# Auto-fix what's possible
tinylang lint --fix main.tiny
Output
warning [prefer-const] main.tiny:3:5: Variable 'x' is never reassigned, use 'const'
error [unreachable-code] main.tiny:12:3: Unreachable code after 'return'
test
Run test files containing test blocks.
tinylang test [files...]
If no files are specified, automatically finds all *.test.tiny files recursively.
Examples
# Run all tests
tinylang test
# Run specific test files
tinylang test main.test.tiny lib.test.tiny
Output
main.test.tiny
✓ addition works
✓ string concatenation
✗ division by zero handling
Expected: "error" Got: null
Tests: 2 passed, 1 failed
doc
Generate documentation from source file comments.
tinylang doc <file.tiny> [options]
Options
| Flag | Short | Description |
|---|---|---|
--output <path> | -o | Write output to file (default: stdout) |
Examples
# Print docs to stdout
tinylang doc lib.tiny
# Write to a markdown file
tinylang doc lib.tiny -o docs/api.md
init
Scaffold a new TinyLang project with standard files.
tinylang init [name]
Examples
# Create new project directory
tinylang init my-project
# Initialize in current directory
tinylang init .
Created Files
my-project/
main.tiny - Entry point
lib.tiny - Library module
main.test.tiny - Test file
.tinylang.json - Configuration
README.md - Documentation
bench
Benchmark program execution with detailed statistics.
tinylang bench <file.tiny> [options]
Options
| Flag | Short | Description |
|---|---|---|
--iterations <N> | -n | Number of iterations (default: 100) |
--compare | Compare interpreter vs. VM performance |
Examples
# Basic benchmark
tinylang bench fib.tiny
# 1000 iterations, compare modes
tinylang bench fib.tiny -n 1000 --compare
Output
Benchmarking: fib.tiny
Iterations: 1000
Interpreter:
min: 0.12ms
max: 1.45ms
avg: 0.18ms
median: 0.15ms
Compiler+VM:
min: 0.04ms
max: 0.52ms
avg: 0.06ms
median: 0.05ms
VM is 3.00x faster than interpreter
repl
Start the interactive Read-Eval-Print Loop.
tinylang repl
The REPL maintains state between lines, so you can define variables and functions that persist throughout the session. Use Ctrl+C to exit.
wasm
Compile function declarations to WebAssembly Text Format (.wat).
tinylang wasm <file.tiny> [options]
Options
| Flag | Short | Description |
|---|---|---|
--output | -o | Output .wat file path |
The target covers a deliberately narrow subset: integer functions, parameters, locals,
if/else, while, direct calls and recursion, arithmetic,
comparisons, and and/or. Every value is an i32.
A function that uses anything outside that subset is left out of the module entirely and is not exported. That is reported as an error, not a warning, and the command exits non-zero, because the export the caller asked for does not exist in the output.
Examples
$ tinylang wasm mixed.tiny
1 function(s) could not be compiled to WASM:
- describe: unsupported expression type for WASM: StringLiteral
These functions are absent from the module and are not exported.
Note: 1 top-level statement(s) were left out (the WASM target compiles function declarations only).
Compiled to WebAssembly: mixed.wat (181 bytes)
Compiled and exported: addUp
Incomplete: 1 function(s) compiled, 1 could not be.
$ echo $?
1
The .wat file is still written when at least one function compiled, so the
functions that did translate remain usable; if no function is expressible in the subset,
nothing is written at all. Top-level statements are not part of the WASM output and are
reported as a note rather than an error. The compiler never emits a stand-in for an operation
it cannot translate.
check
Check a file for syntax errors without executing it.
tinylang check <file.tiny>
Examples
tinylang check main.tiny
# Output: main.tiny: No errors found!
version
Display version and platform information.
tinylang version
# TinyLang v1.0.0
# Runtime: Node.js v22.x.x
# Platform: linux x64
help
Show the help message with all available commands.
tinylang help
tinylang --help
File Extensions
| Extension | Description |
|---|---|
.tiny | TinyLang source file |
.tinyc | Compiled bytecode file |
.test.tiny | Test file (discovered by tinylang test) |
.tinylang.json | Project configuration (formatter/linter settings) |
Configuration
Create a .tinylang.json in your project root to configure the formatter and linter:
{
"formatter": {
"indentSize": 2,
"maxLineWidth": 80,
"insertFinalNewline": true
},
"linter": {
"rules": {
"prefer-const": "warning",
"no-unused-variables": "warning",
"no-empty-blocks": "warning",
"unreachable-code": "error",
"no-shadow": "info"
}
}
}