Skip to content

CLI

The Purus CLI provides commands for compiling, running, checking, and managing Purus projects.

CommandDescription
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 initInitialize project in current directory
purus versionShow version
purus helpShow help

Aliases: compile = build, create = new

Compile Purus source files to JavaScript. Supports single file, directory, and config-based compilation.

Terminal window
purus build hello.purus
# Output: hello.js
purus build app.cpurus
# Output: app.cjs
purus build lib.mpurus
# Output: lib.mjs
ExtensionOutputFormat
.purus.jsStandard JavaScript
.cpurus.cjsCommonJS module
.mpurus.mjsES Module

Compile all .purus, .cpurus, and .mpurus files in a directory. The output directory structure mirrors the source.

Terminal window
# Compile all files in src/ to dist/
purus build --directory src
# Specify output directory
purus build --directory src --output build

When no file or directory is specified, Purus reads config.purus from the current or parent directory.

Terminal window
# Uses entry and output from config.purus
purus build

See config.purus for configuration details.

OptionAliasDescription
--directory <dir>-dCompile all Purus files in the directory
--output <dir>-oSpecify output directory (overrides config.purus)
--no-headerOmit the // Generated by Purus header comment
--stdoutPrint compiled JavaScript to stdout instead of writing files
Terminal window
# Compile without header comment
purus build --no-header hello.purus
# Print compiled output to stdout
purus build --stdout hello.purus
# Compile directory with custom output
purus build -d src -o build
# Compile with config, override output directory
purus build --output public/js

Compile and run Purus files without generating output files. Useful for quick testing and development.

Terminal window
purus run hello.purus

Run all Purus files in a directory:

Terminal window
purus run --directory src
Terminal window
# Uses entry from config.purus
purus run
OptionAliasDescription
--directory <dir>-dRun all Purus files in the directory

Check Purus source code for syntax errors without compiling. Prints OK: <file> if the syntax is valid.

Terminal window
purus check hello.purus
# OK: hello.purus

Create a new Purus project with an interactive setup. The target directory must not exist or must be empty.

Terminal window
# Interactive setup
purus new my-project
# Skip all prompts
purus new my-project -y
FileDescription
src/main.purusEntry point with Hello World example
config.purusBuild and lint configuration
.prettierrcPrettier configuration for Purus
README.mdProject README with scripts reference
.gitignoreGit ignore rules
package.jsonnpm package with scripts
ScriptCommandDescription
puruspurusRun purus CLI
buildpurus buildCompile project
compilepurus compileCompile project (alias)
execpurus runRun project
formatprettier --write ./srcFormat source files
lintpurus-lintLint source files

When prompted (or with -y), the following packages are installed:

  • purus — Compiler
  • @puruslang/linter — Linter
  • @puruslang/prettier-plugin-purus — Prettier plugin
  • prettier — Code formatter

Initialize a Purus project in the current directory. Creates src/ and src/main.purus if they don’t exist.

Terminal window
purus init

Display the installed Purus version.

Terminal window
purus version
# purus v0.2.1

Aliases: purus --version, purus -v


Display the help message with all available commands.

Terminal window
purus help

Aliases: purus --help, purus -h


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 settings
const lint.no-var be ///warn///
const lint.indent-size be 2
const lint.max-line-length be ///off///
KeyTypeDefaultDescription
entrystring"src"Source directory
outputstring"dist"Output directory
headerbooleantrueInclude // Generated by Purus header comment
KeyTypeDefaultDescription
lint.no-varstring"warn""warn" or "error" on var usage
lint.indent-sizenumber2Expected indentation size
lint.max-line-lengthstring/number"off"Maximum line length ("off" to disable)

The following commands read config.purus automatically when no file arguments are given:

  • purus build — Uses entry, output, and header settings
  • purus run — Uses entry setting
  • purus-lint — Uses lint.* settings and entry for file discovery

Command-line options (e.g. --output, --directory) override config values.


Purus can also be used as a Node.js library.

const { compile, check, version } = require("purus");

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"
OptionTypeDefaultDescription
headerbooleantrueInclude header comment

Check Purus source code for syntax errors. Returns true if valid, throws an error otherwise.

check("const x be 42"); // => true
check("const x be"); // throws Error

The current Purus version string.

console.log(version); // => "0.2.1"