CLI reference

The legion command is the entry point for everything: running files, the REPL, static checking, formatting, project scaffolding, and the package manager.

legion run

Runs a .lhj file.

bash
legion run hello.lhj
legion run ./src/main.lhj
legion run --debug app.lhj    ## extra debug output

legion repl

Opens the interactive REPL.

bash
legion repl

Inside the REPL, type :help for a list of REPL-specific commands.

legion check

Runs a static analysis pass over a file. Reports type mismatches, undefined variables, and other issues without running the program.

bash
legion check app.lhj
legion check src/

legion fmt

Formats a .lhj file in place according to the standard style (2-space indent, spaces around operators, newline at EOF).

bash
legion fmt app.lhj           ## format single file
legion fmt --dry-run app.lhj ## show diff without writing
legion fmt src/              ## format all .lhj files in directory

legion new

Scaffolds a new project directory.

bash
legion new my-project

Creates:

lhj
my-project/
  main.lhj
  legion.pkg
  legion.lock
  README.md

legion pkg

Package manager subcommand. See Package manager for the full reference.

bash
legion pkg install legion-colors
legion pkg remove legion-colors
legion pkg list
legion pkg search http
legion pkg init
legion pkg publish

legion version

Prints version information.

bash
legion version
lhj
legionhjyu 1.0.0
Python 3.12.0

legion help

Prints help for any command.

bash
legion help
legion help run
legion help pkg

Exit codes

CodeMeaning
0Success
1Runtime error in the script
2CLI usage error (bad arguments)
3File not found