The falx CLI & REPL

There's no standalone falx binary yet - everything runs through python -m src.Main from inside a clone of the repository (see Installation). This page documents every subcommand as implemented in src/ArgumentHandler.py on master.

Running a script

$ python -m src.Main run path/to/script.flx

run also has two aliases wired up as sub-command aliases, so these are equivalent:

$ python -m src.Main --file path/to/script.flx
$ python -m src.Main -f path/to/script.flx

Exit code is 0 on success. Lexer, parser and runtime errors are caught and printed as a formatted diagnostic (with a source location) rather than a Python traceback, and the process exits with code 1.

The REPL

Running the command with no subcommand at all drops you into an interactive REPL, line by line:

$ python -m src.Main
Falx REPL
Type 'exit()' to exit
>> let x = 4;
>> output(x * 2);
8
>> exit()

The REPL shares a single interpreter and global scope across lines, so variables and functions you define persist for the rest of the session. It also defines a REPL-only exit() function that isn't available inside a normal script. Errors in one line are printed as a diagnostic and don't end the session.

Checking the version

$ python -m src.Main --version
Falx v0.3.0
$ python -m src.Main -v
Falx v0.3.0

(The version number above is fetched live from GitHub's CHANGELOG.md - see Changelog.)

Running the interpreter's test suite

This is for working on Falx itself, not for testing your own .flx programs. test (alias -t) runs every program under tests/programs and compares its output against a matching .out snapshot file:

$ python -m src.Main test
FlagEffect
--update-snapshotsOverwrites the .out files with the interpreter's current output instead of comparing against them.
--filter <text>Only runs test programs whose filename contains the given text.

A note on modules and the CLI

require("name") (see Modules) resolves .flx files relative to the file doing the requiring, and refuses to resolve outside the directory the entry script lives in. This only matters once you start splitting a program across files - it isn't a CLI flag, but it does affect which script you should point run at (the "entry" file, not a file it requires).