Skip to content

CLI

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

CommandDescription
purus build [file|dir]Compile Purus files to JavaScript
purus run [file|dir]Compile and run without generating files
purus check [file|dir]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 src
# Specify output directory
purus build src --output build
# Using --entry flag
purus build --entry src
purus build -e src -o 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
--entry <file|dir>-eSpecify entry file or directory
--output <dir>-oSpecify output directory (overrides config.purus)
--no-headerOmit the // Generated by Purus header comment
--strict [true|false]Enable/disable strict mode (default: true)
--type <type>-tSet module type: module (ESM) or commonjs (CJS)
--stdoutPrint compiled JavaScript to stdout instead of writing files

You can also pass a file or directory as a positional argument instead of using --entry.

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 src -o build
# Using --entry flag
purus build -e 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 src
# Using --entry flag
purus run --entry src
purus run -e src
Terminal window
# Uses entry from config.purus
purus run
OptionAliasDescription
--entry <file|dir>-eSpecify entry file or directory
--strict [true|false]Enable/disable strict mode (default: true)

You can also pass a file or directory as a positional argument instead of using --entry.


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

Check all Purus files in a directory:

Terminal window
purus check src
# Using --entry flag
purus check --entry src
purus check -e src
Terminal window
# Uses entry from config.purus
purus check
OptionAliasDescription
--entry <file|dir>-eSpecify entry file or directory

You can also pass a file or directory as a positional argument instead of using --entry.


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

Output: Purus v ...

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 type be ///module///
const header be true
const strict be true
-- Linter settings
const lint.no-var be ///warn///
const lint.no-nil be ///off///
const lint.indent-size be 2
const lint.max-line-length be ///off///
const lint.no-trailing-whitespace be ///warn///
const lint.no-unused-import be ///warn///
const lint.consistent-naming be ///off///
KeyTypeDefaultDescription
entrystring"src"Source directory
outputstring"dist"Output directory
typestring"module"Module type: "module" (ESM) or "commonjs" (CJS)
headerbooleantrueInclude // Generated by Purus header comment
strictbooleantrueEnable strict mode ("use strict" at top of output)
KeyTypeDefaultDescription
lint.no-varstring"warn""warn" or "error" on var usage
lint.no-nilstring"off""warn" or "error" on nil usage
lint.indent-sizenumber2Expected indentation size
lint.max-line-lengthstring/number"off"Maximum line length ("off" to disable)
lint.no-trailing-whitespacestring"warn""warn" or "error" on trailing whitespace
lint.no-unused-importstring"warn""warn" or "error" on unused imports
lint.consistent-namingstring"off""warn" or "error" for naming convention checks

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

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

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


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

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

Purus ships with built-in TypeScript type definitions. No additional @types package is needed.

import { compile, check, version } from "purus";
const js: string = compile("const x be 42", { header: false, strict: true, type: "module" });
const valid: true = check("const x be 42");
console.log(version); // string

Compile Purus source code to JavaScript.

The header comment includes the installed Purus version (currently ... ):

const js = compile("const x be 42");
// => "// Generated by Purus x.y.z\n\"use strict\";\nconst x = 42;\n"
const js = compile("const x be 42", { header: false });
// => "\"use strict\";\nconst x = 42;\n"
OptionTypeDefaultDescription
headerbooleantrueInclude header comment
strictbooleantrueEnable strict mode ("use strict" at top of output)
typestring"module"Module type: "module" (ESM) or "commonjs" (CJS)

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); // => "x.y.z"