CLI Reference
The Zym CLI is a single binary that compiles, runs, packages, and inspects Zym programs.
Quick Reference
| Command | Description |
|---|---|
zym |
Show help information |
zym <file.zym> |
Compile and run source file |
zym <file.zbc> |
Run precompiled bytecode |
zym <file.zym> -o <out.zbc> |
Compile to bytecode |
zym <file.zym> -o <out.exe> |
Compile to standalone executable |
zym <file.zbc> -o <out.exe> |
Pack bytecode into executable |
zym <file> -o <out> -r <runtime> |
Cross-platform packing with explicit runtime |
zym <file> --dump |
Disassemble to console |
zym <file> --dump <out.txt> |
Disassemble to file |
zym <file> --strip |
Strip debug info (smaller output) |
zym <file.zym> --preprocess |
Show preprocessed source |
zym <file.zym> --combined |
Show combined source with modules |
zym --version |
Print version |
File Types
.zym— Zym source file.zbc— Compiled Zym bytecode (portable across platforms).exe/ extensionless — Standalone executable (bytecode embedded in runtime)
Script Arguments
Pass arguments to your script using -- as a delimiter. Everything after -- is forwarded to the script's main(argv) function.
zym app.zym -- --port 8080 --verbose
func main(argv) { print(argv); // → ["zym", "--port", "8080", "--verbose"] }
Built-in Functions
print(value)
print(format, ...args)
Prints a value to standard output followed by a newline. When called with a single argument, print outputs the value directly. When called with a format string and additional arguments (up to 25), it performs formatted output with type-checked placeholders.
print("Hello, World!") // Hello, World! print(42) // 42 print([1, 2, 3]) // [1, 2, 3] print(true) // true
print("Name: %s, Age: %n", "Alice", 30) // Name: Alice, Age: 30 print("Result: %v", [1, 2, 3]) // Result: [1, 2, 3] print("Score: %n%% out of 100", 95) // Score: 95% out of 100
Format Specifiers
| Specifier | Type | Description |
|---|---|---|
%v |
any | Auto-format any value (no type check) |
%s |
string | String value (type-checked) |
%n |
number | Number — integers print without decimals (type-checked) |
%b |
bool | Boolean — prints true or false (type-checked) |
%l |
list | List value (type-checked) |
%m |
map | Map value (type-checked) |
%t |
struct | Struct instance (type-checked) |
%e |
enum | Enum value (type-checked) |
%f |
function | Function value (type-checked) |
%r |
reference | Reference value (type-checked) |
%% |
— | Literal percent sign |
%v when you don't need type enforcement.
clock()
Returns the elapsed CPU time in seconds as a number. Useful for benchmarking and measuring execution time of code sections.
var start = clock() var sum = 0 for (var i = 0; i < 1000000; i = i + 1) { sum = sum + i } var elapsed = clock() - start print("Took %n seconds", elapsed)
sleep(milliseconds)
Pauses execution for the given number of milliseconds. The argument must be a non-negative number.
print("Starting...") sleep(1000) // Wait 1 second print("Done!")
Native Modules
The CLI extends the core language with native modules for system interaction. These are available only when running scripts through the CLI binary, not in the embedded library.
Console
Terminal input, raw mode, cursor control, and ANSI styling.
File I/O
Read, write, append, and manage files and directories.
Buffer
Binary data buffers for raw byte manipulation.
OS
Environment variables, platform detection, and system info.
Process
Spawn child processes, capture output, and manage execution.
Random
Random number generation and seeding.
ZymVM
Runtime introspection and VM control from script code.