> Agent-readable docs index: /llms.txt. Download /docs.zip to grep all markdown files locally.

---
$schema: https://holocron.so/frontmatter.json
title: CLI Reference
description: rbcpp command reference for checking, running, building C, and PLCopen import/export on IEC 61131-3 files.
icon: lucide:terminal
---

The **`rbcpp` CLI** is implemented by the `rbcpp_cli` crate. During development, invoke it with `cargo run -p rbcpp_cli --`.

## Commands

| Command                     | Purpose                                                                                                            |
| --------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| `check <file>`              | Parse and semantically check an IEC project (`.st`, `.il`, `.sfc`, `.ld`, `.fbd`, or PLCopen `.xml`).              |
| `run <file>`                | Execute a supported program or configuration for one or more scan cycles. See [Execution model](/execution-model). |
| `build-c <file>`            | Generate portable C for a checked **PROGRAM** (not a full configuration scheduler).                                |
| `import-plcopen <file.xml>` | Import PLCopen XML and report discovered POUs.                                                                     |
| `export-plcopen <file>`     | Export a parsed project as PLCopen XML.                                                                            |
| `compliance`                | Print the profile compliance matrix.                                                                               |
| `todos`                     | Print non-implemented leaf rows from the matrix (empty for `2003-strict` today).                                   |
| `parameters`                | Report Annex D-style implementation-dependent parameters.                                                          |
| `sfc-compliance`            | Report SFC compatible/minimal compliance-set status.                                                               |

<Aside>
  <Tip>
    Pass **`--json`** to `check`, `run`, `import-plcopen`, `compliance`, `todos`, `parameters`, and `sfc-compliance` when integrating with CI or editor tooling.
  </Tip>
</Aside>

## Input file extensions

| Extension | Loader                                                    |
| --------- | --------------------------------------------------------- |
| `.st`     | Textual IEC project (ST, IL, SFC bodies)                  |
| `.il`     | Same parser as `.st` (IL-first projects)                  |
| `.sfc`    | Same parser as `.st` (SFC-first projects)                 |
| `.ld`     | Native textual Ladder Diagram (`LADDER` / `RUNG`)         |
| `.fbd`    | Native textual Function Block Diagram (`FBD` / `NETWORK`) |
| `.xml`    | PLCopen import via `iec_plcopen`                          |

## Command semantics

**`check`** runs semantic analysis only when parse/import produced **no diagnostics at all**. If parsing already emitted errors or warnings, **`check_project`** is skipped. Fix parse issues first; do not assume a clean exit means full type-checking when warnings remain.

**`run`** and **`build-c`** always call **`check_project`**, regardless of earlier parse warnings.

**`export-plcopen`** accepts any supported input extension (`.st`, `.il`, `.sfc`, `.ld`, `.fbd`, `.xml`). It serializes the parsed IR back to XML without running semantic checking. Only parse/import **errors** block export; semantically invalid but parseable projects can still serialize to XML.

**`import-plcopen`** always exits **0** even when diagnostics are printed. Inspect stderr or use **`--json`** for the diagnostic list.

**`parameters`** accepts **`--profile`** for JSON metadata but always reports **`ImplementationParameters::default()`** limits. Profile selection does not change Annex D numbers today.

**`build-c`** without **`-o`** writes generated C to **stdout**.

## Common options

| Option                        | Used By                                                                          | Notes                                                                                                                                                                                                                                                                                |
| ----------------------------- | -------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `--json`                      | Most commands above                                                              | Emits JSON for diagnostics or command output. See [Diagnostics](/diagnostics).                                                                                                                                                                                                       |
| `--profile <name>`            | `check`, `run`, `build-c`, `compliance`, `todos`, `parameters`, `sfc-compliance` | Defaults to `2003-strict`.                                                                                                                                                                                                                                                           |
| `--program <name>`            | `run`, `build-c`                                                                 | Selects a program when multiple POUs are present.                                                                                                                                                                                                                                    |
| `--configuration <name>`      | `run` only                                                                       | Runs a configuration instead of a standalone program.                                                                                                                                                                                                                                |
| `--cycles <n>`                | `run`                                                                            | Sets deterministic scan-cycle count.                                                                                                                                                                                                                                                 |
| `--access [CYCLE:]NAME=VALUE` | `run`                                                                            | Injects writes through `VAR_ACCESS` paths during simulation. Prefix with a cycle number to schedule a write on a specific scan (for example `1:PublicSetpoint=42`). Names that contain `:` but do not start with digits are treated as a single path (for example `Public:Count=1`). |
| `-o, --output <path>`         | `build-c`, `export-plcopen`                                                      | Writes generated output to a file.                                                                                                                                                                                                                                                   |

## Profiles

The profile parser currently accepts:

| Profile                                  | Meaning                                                                                                        |
| ---------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
| `2003`, `2003-strict`, `iec61131-3:2003` | Claimable strict IEC 61131-3:2003 profile.                                                                     |
| `2003-plus`, `2003-plus-extensions`      | Claimable 2003 profile; relaxes `__` and trailing `_` in identifiers only. Does not enable pragmas in the CLI. |
| `2013`, `2013-placeholder`               | Placeholder only. No compliance claim; check fails.                                                            |
| `2025`, `2025-placeholder`               | Placeholder only. No compliance claim; check fails.                                                            |

## Build C

```bash
cargo run -p rbcpp_cli -- build-c examples/counter.st -o build/counter.c
```

Requires a clean **`check`** first. Output is portable C with scan functions, state structs, **target hook tables**, `rbcpp_io_symbols` metadata, retained-state load/save, comm hooks, and `VAR_ACCESS` helpers. See [Targets and Generated C](/targets).

**`build-c`** calls `generate_c` with an optional **`--program`** name only. It does not emit a full **CONFIGURATION** scheduler; use **`run --configuration`** for configuration simulation.

## Sample invocations

```bash
cargo run -p rbcpp_cli -- check examples/function_blocks.st --json
cargo run -p rbcpp_cli -- run examples/configuration.st --configuration Plant --cycles 2
cargo run -p rbcpp_cli -- run controller.st --cycles 2 --access PublicInput=TRUE --access 1:PublicSetpoint=42
cargo run -p rbcpp_cli -- export-plcopen examples/counter.st -o build/counter.xml
cargo run -p rbcpp_cli -- export-plcopen examples/plcopen_fbd.xml -o build/reexport.xml
cargo run -p rbcpp_cli -- compliance --profile 2003-strict
cargo run -p rbcpp_cli -- todos --profile 2003-strict
cargo run -p rbcpp_cli -- parameters --json
cargo run -p rbcpp_cli -- sfc-compliance --profile 2003-strict
```

<CardGroup cols={2}>
  <Card title="PLCopen" icon="lucide:file-code" href="/plcopen">
    Import, export, and LD/FBD lowering.
  </Card>

  <Card title="Targets" icon="lucide:cpu" href="/targets">
    Generated C hooks and rbcpp\_target.
  </Card>

  <Card title="Examples" icon="lucide:folder-open" href="/examples">
    All repository examples (.st, .il, .sfc, .ld, .fbd, .xml).
  </Card>
</CardGroup>


---

*Powered by [holocron.so](https://holocron.so)*
