This is the command surface implemented in the current tree.
Examples use the installed rex form, then show the source-checkout form where it matters.
Command forms:
rex <command> ...Source checkout form:
cd rex
lua compiler/cli/rex.lua <command> ...Examples use the installed form (rex ...).
Use rex version or rex --version to inspect the CLI release version.
Use rex check-update to compare the installed CLI version against the latest published release.
The version field written to rex.toml is the project/package version, not the Rex release number.
Create a new project skeleton.
rex init <dir>Creates:
<dir>/rex.toml<dir>/src/main.rex
The generated manifest includes:
version = "0.1.0"as the new project's package versionentry = "src/main.rex"
Parse + typecheck + generate C, and (by default) compile native binary.
rex build [input] [options]Default input:
- explicit
[input]if provided - otherwise
entryfromrex.tomlin the current project root - fallback:
src/main.rex
Options:
--out <path>: native output path--c-out <path>: generated C output path--no-entry: generate code withoutmainentry wrapper--no-native: skip native compilation (generate C only)--cc <compiler>: C compiler command--mode release|debug: build mode
Examples:
rex build examples/hello.rex
rex build examples/hello.rex --no-native --c-out build/hello.c
rex build src/main.rex --mode debug --cc clangAdd a dependency to rex.toml.
rex add [name] --path <path>
rex add [name] --git <url> --rev <revision>Notes:
- if
<name>is omitted, Rex infers it from the path segment or git repo name - git dependencies must be pinned with
--rev
Example:
rex add utils --path ../utils
rex add jsonx --git https://github.com/example/jsonx --rev 4e2d9f1Remove a dependency from rex.toml.
rex remove <name>Example:
rex remove utilsValidate dependencies and write rex.lock.
rex installCurrent scope:
- validates each path or git dependency
- loads nested dependencies
- fetches git dependencies into the Rex package cache
- detects dependency cycles
- writes a lockfile snapshot
- enables compiler-side package imports for dependency entry files
Current import model:
use libmath as lm
fn main() {
println(lm.answer())
}Current exported package surface:
pub fnthroughpkg.fn()pub structthroughpkg.Type.new(...)pub enumthroughpkg.Enum.Variant(...)orpkg.Enum.Variantpub typethroughpkg::Aliasin type positions
Current limitations:
- imported struct literals are not package-qualified yet; use constructors
- dependency type names must stay unique across the resolved graph for now
Print the resolved dependency list for the current project.
rex depsBuild then execute a Rex file.
rex run [input] [options]Default input:
- explicit
[input]if provided - otherwise
entryfromrex.tomlin the current project root - fallback:
src/main.rex
Options:
--out <path>--c-out <path>--cc <compiler>--mode release|debug
Example:
rex run examples/hello.rex
rex run examples/test_struct_lit.rexRun benchmark file multiple times and report elapsed stats.
rex bench [input] [options]Default input:
examples/benchmark.rex
Options:
--runs <n>(must be >= 1)--cc <compiler>--mode release|debug
Example:
rex bench examples/benchmark.rex --runs 10Build all example files to C.
rex testThis validates parsing/typechecking/codegen across the full example set,
including regression samples for newer syntax such as struct literals,
compound assignment, and richer match arms.
It is a regression sweep for the shipped examples, not a full language conformance suite yet.
Format a source file (currently trims trailing spaces and normalizes ending newline).
rex fmt [input]Default input:
- explicit
[input]if provided - otherwise
entryfromrex.tomlin the current project root - fallback:
src/main.rex
Run parser + typechecker validation.
rex lint [input]Default input:
- explicit
[input]if provided - otherwise
entryfromrex.tomlin the current project root - fallback:
src/main.rex
Same validation pipeline as lint, intended as quick correctness check.
rex check [input]Default input:
- explicit
[input]if provided - otherwise
entryfromrex.tomlin the current project root - fallback:
src/main.rex
Example:
rex check examples/test_multi_match.rexPrint the Rex CLI release version.
rex version
rex v
rex --versionCompare the installed Rex CLI version against the latest published GitHub release.
rex check-updateCurrent behavior:
- checks the latest published release tag from GitHub
- compares it to the installed CLI version
- prints the release link when an update is available
- does not download or install updates automatically
release: optimized build (default)debug: debug-friendly build flags
You can also set mode through environment:
REX_BUILD_MODEREX_MODE
CC: default C compilerREX_BUILD_MODE/REX_MODE: default build modeREX_CFLAGS: extra C compiler flagsREX_OPT_FLAG: override optimization behavior
Before lexing/parsing, Rex can expand includes using comments:
// @include "relative/path.rex"Include cycles are detected and reported as errors.