The HypnoScript Command Line Interface (CLI) is the fastest tool to build, check, and run HypnoScript scripts. This page guides you through the most important subcommands and typical workflows.
Help & Orientation
bash
# Global help
hypnoscript --help
# Show version and features
hypnoscript version
# Help for a subcommand
hypnoscript run --help
The output always lists all available subcommands and their options. If a command seems unfamiliar, it's worth looking at --help – the text is generated directly from the actual CLI.
Running Scripts
bash
# Standard execution
hypnoscript run demo.hyp
# With additional output
hypnoscript run demo.hyp --verbose
# With debug information
hypnoscript run demo.hyp --debug
--verboseoutputs status messages like "Running file" or success messages.--debugadditionally shows source code, token list, type checking results and the interpretation flow.- Errors in the type checker don't stop execution – they are reported, then the interpreter continues.
Analysis Tools
| Command | Purpose |
|---|---|
hypnoscript lex <file> | Shows all tokens with index, type and lexeme |
hypnoscript parse <file> | Outputs the formatted Abstract Syntax Tree |
hypnoscript check <file> | Checks types and reports inconsistencies |
hypnoscript compile-wasm <file> | Generates WebAssembly Text Format (.wat) |
These tools can be ideally combined to narrow down parser or type errors. Example:
bash
hypnoscript check scripts/report.hyp
hypnoscript parse scripts/report.hyp
hypnoscript compile-wasm scripts/report.hyp -o report.wat
Exploring the Standard Library
bash
hypnoscript builtins
The command groups all built-in functions by category (Math, String, Array, System, ...). Use it to quickly find suitable helpers.
Typical Workflow
- Preparation – Run
hypnoscript checkon all scripts. - Error Analysis – Use
lexorparsefor problems to inspect the specific section. - Execution – Test with
run, activate--debugif needed. - Deployment – Optionally use
compile-wasmif the script should run in the browser or a WASM environment.
bash
# Example: complete round
hypnoscript check examples/inventory.hyp
hypnoscript run examples/inventory.hyp --debug
hypnoscript compile-wasm examples/inventory.hyp -o inventory.wat
Tips & Tricks
- Quick Iteration: Use
--debugas soon as something seems odd – tokens and AST immediately reveal whether the parser understood your intention. - Bundle Outputs: Pipe the output to a file (
hypnoscript run script.hyp > output.txt) to document longer runs. - Platform-agnostic: On Windows, macOS and Linux, the commands are identical. The only requirement is that the
hypnoscriptbinary is in thePATH. - Tests as Scripts: The files in the
hypnoscript-tests/folder can be started directly withhypnoscript run. This shows you real examples of control flow and sessions.
Further Links
- CLI Overview – Installation, binary variants and workflow
- CLI Commands – Complete reference with all options
- Language Reference – Detailed grammar description