CLI

The `bao` CLI is Baobab's command-line tool. It uses the exact same engine as the online IDE, so your programs run identically locally and in the browser. This page walks through every command, its options and its output — no prior experience required.

Install & check

The online IDE needs no install. A one-line installer (get.baobablang.dev) is on the way; meanwhile the `bao` CLI ships with the open-source toolchain (Python 3.13+).

# À venir — installeur en une ligne (macOS / Linux) :
# curl -fsSL get.baobablang.dev | sh

bao --version    # → bao 0.1.0
bao --help       # liste toutes les commandes
Global options
-h, --helpShow help (global or per-command) and exit. E.g. `bao run --help`.
--versionShow the Baobab version and exit.

Commands

bao run
bao run <file> [--seed N] [--timeout S]

Runs a `.bao` (or `.py`) file. It automatically follows local imports (`importer … depuis "./x.bao"`), checks the syntax before running, prints the program's output, and returns the program's exit code. On error, the traceback is shown with French names (`ErreurValeur`, `ErreurCle`…) and points at your `.bao` file.

Options
--seed NSeed the random module (`aleatoire`) for reproducible runs.
--timeout SMaximum execution time in seconds (default: 5).
Examples
bao run main.baoRun the program.
bao run jeu.bao --seed 42Deterministic randomness.
bao translate
bao translate <file> [--to python|bao] [-o <file>] [-w]

Converts code both ways while preserving indentation, comments and blank lines. The direction is inferred from the extension (`.bao` → Python, `.py` → Baobab) or forced with `--to`. With no output option the result is printed to standard output; `-o` writes to the given file, `-w` writes next to the source.

Options
--to python|baoTarget language (default: inferred from the extension).
-o, --output <file>Write the result to this file.
-w, --writeWrite next to the source, swapping the extension.
Examples
bao translate main.bao --to pythonPrint the Python translation.
bao translate app.py -wCreate app.bao next to app.py.
bao build
bao build [<path>] [-o <dir>]

Walks a directory (or a file) and transpiles every `.bao` to `.py` into an output directory (default: `build/`), preserving the subfolder structure. Each file's syntax is checked; on error it is reported and that file is skipped.

Options
<path>File or directory to build (default: current directory).
-o, --output <dir>Output directory (default: build).
Examples
bao build src -o distTranspile src/ into dist/.
bao test
bao test [<path>]

Discovers and runs every file named `test_*.bao` or `*_test.bao` under the given directory. A test passes if its program exits with code 0 (use `affirmer` to check your assumptions). A `N passed, M failed` summary is printed; the command returns a non-zero code if any test fails.

Options
<path>Directory to scan (default: current directory).
Examples
bao test testsRun every test under tests/.
bao format
bao format <path>...

Tidies the layout: converts tabs to 4 spaces, strips trailing whitespace and ensures a single final newline. Accepts files and directories (recursive over `.bao`). Changed files are listed.

Options
<path>...One or more files or directories to format.
Examples
bao format srcFormat every .bao in src/.
bao install
Coming soon
bao install <package>

Will install packages from the future Baobab community registry. This command is not available yet: the package manager and registry are planned for a later phase. For now it prints a message and exits without installing anything.

Examples
bao install math-frSoon: install the math-fr package.

Exit codes

Every command returns an exit code you can check in scripts and CI.

0Success (or the run program's own exit code).
1Syntax error, runtime error, or failing tests.
2Misuse: file not found, invalid argument, unavailable command.
124Execution timed out (see --timeout).