CLI
The Purus CLI provides commands for compiling, running, checking, and managing Purus projects.
Quick Reference
Section titled “Quick Reference”| Command | Description |
|---|---|
purus build [file] | Compile Purus files to JavaScript |
purus run [file] | Compile and run without generating files |
purus check <file> | Syntax check only |
purus new [name] | Create a new project |
purus init | Initialize project in current directory |
purus version | Show version |
purus help | Show help |
Aliases: compile = build, create = new
Commands
Section titled “Commands”purus build / purus compile
Section titled “purus build / purus compile”Compile Purus source files to JavaScript. Supports single file, directory, and config-based compilation.
Single file
Section titled “Single file”purus build hello.purus# Output: hello.js
purus build app.cpurus# Output: app.cjs
purus build lib.mpurus# Output: lib.mjs| Extension | Output | Format |
|---|---|---|
.purus | .js | Standard JavaScript |
.cpurus | .cjs | CommonJS module |
.mpurus | .mjs | ES Module |
Directory
Section titled “Directory”Compile all .purus, .cpurus, and .mpurus files in a directory. The output directory structure mirrors the source.
# Compile all files in src/ to dist/purus build --directory src
# Specify output directorypurus build --directory src --output buildUsing config.purus
Section titled “Using config.purus”When no file or directory is specified, Purus reads config.purus from the current or parent directory.
# Uses entry and output from config.puruspurus buildSee config.purus for configuration details.
Options
Section titled “Options”| Option | Alias | Description |
|---|---|---|
--directory <dir> | -d | Compile all Purus files in the directory |
--output <dir> | -o | Specify output directory (overrides config.purus) |
--no-header | Omit the // Generated by Purus header comment | |
--stdout | Print compiled JavaScript to stdout instead of writing files |
Examples
Section titled “Examples”# Compile without header commentpurus build --no-header hello.purus
# Print compiled output to stdoutpurus build --stdout hello.purus
# Compile directory with custom outputpurus build -d src -o build
# Compile with config, override output directorypurus build --output public/jspurus run
Section titled “purus run”Compile and run Purus files without generating output files. Useful for quick testing and development.
Single file
Section titled “Single file”purus run hello.purusDirectory
Section titled “Directory”Run all Purus files in a directory:
purus run --directory srcUsing config.purus
Section titled “Using config.purus”# Uses entry from config.puruspurus runOptions
Section titled “Options”| Option | Alias | Description |
|---|---|---|
--directory <dir> | -d | Run all Purus files in the directory |
purus check
Section titled “purus check”Check Purus source code for syntax errors without compiling. Prints OK: <file> if the syntax is valid.
purus check hello.purus# OK: hello.puruspurus new / purus create
Section titled “purus new / purus create”Create a new Purus project with an interactive setup. The target directory must not exist or must be empty.
# Interactive setuppurus new my-project
# Skip all promptspurus new my-project -yWhat it creates
Section titled “What it creates”| File | Description |
|---|---|
src/main.purus | Entry point with Hello World example |
config.purus | Build and lint configuration |
.prettierrc | Prettier configuration for Purus |
README.md | Project README with scripts reference |
.gitignore | Git ignore rules |
package.json | npm package with scripts |
package.json scripts
Section titled “package.json scripts”| Script | Command | Description |
|---|---|---|
purus | purus | Run purus CLI |
build | purus build | Compile project |
compile | purus compile | Compile project (alias) |
exec | purus run | Run project |
format | prettier --write ./src | Format source files |
lint | purus-lint | Lint source files |
Optional devDependencies
Section titled “Optional devDependencies”When prompted (or with -y), the following packages are installed:
purus— Compiler@puruslang/linter— Linter@puruslang/prettier-plugin-purus— Prettier pluginprettier— Code formatter
purus init
Section titled “purus init”Initialize a Purus project in the current directory. Creates src/ and src/main.purus if they don’t exist.
purus initpurus version
Section titled “purus version”Display the installed Purus version.
purus version# purus v0.2.1Aliases: purus --version, purus -v
purus help
Section titled “purus help”Display the help message with all available commands.
purus helpAliases: purus --help, purus -h
config.purus
Section titled “config.purus”Place a config.purus file in your project root to configure build, run, and lint settings. The file uses Purus syntax itself.
-- Purus Configuration
const entry be ///src///const output be ///dist///const header be true
-- Linter settingsconst lint.no-var be ///warn///const lint.indent-size be 2const lint.max-line-length be ///off///Build settings
Section titled “Build settings”| Key | Type | Default | Description |
|---|---|---|---|
entry | string | "src" | Source directory |
output | string | "dist" | Output directory |
header | boolean | true | Include // Generated by Purus header comment |
Linter settings
Section titled “Linter settings”| Key | Type | Default | Description |
|---|---|---|---|
lint.no-var | string | "warn" | "warn" or "error" on var usage |
lint.indent-size | number | 2 | Expected indentation size |
lint.max-line-length | string/number | "off" | Maximum line length ("off" to disable) |
How config.purus is used
Section titled “How config.purus is used”The following commands read config.purus automatically when no file arguments are given:
purus build— Usesentry,output, andheadersettingspurus run— Usesentrysettingpurus-lint— Useslint.*settings andentryfor file discovery
Command-line options (e.g. --output, --directory) override config values.
Programmatic API
Section titled “Programmatic API”Purus can also be used as a Node.js library.
const { compile, check, version } = require("purus");compile(source, options?)
Section titled “compile(source, options?)”Compile Purus source code to JavaScript.
const js = compile("const x be 42");// => "// Generated by Purus 0.2.1\nconst x = 42;\n"
const js = compile("const x be 42", { header: false });// => "const x = 42;\n"| Option | Type | Default | Description |
|---|---|---|---|
header | boolean | true | Include header comment |
check(source)
Section titled “check(source)”Check Purus source code for syntax errors. Returns true if valid, throws an error otherwise.
check("const x be 42"); // => truecheck("const x be"); // throws Errorversion
Section titled “version”The current Purus version string.
console.log(version); // => "0.2.1"