English | 中文
opm2svg converts an .opl file into an SVG Object-Process Diagram and prints
the parsed model's diagnostics to stderr.
opm2svg <input.opl> [-o out.svg] [--json out.json]
| Option | Meaning |
|---|---|
-o <file> |
Write the SVG to <file>. Default: the input path with a .svg extension (.opl is replaced). |
--json <file> |
Additionally write { things, links, diagnostics } as pretty-printed JSON. |
Options may appear in any order after the input file. A value is required for
both -o and --json; a missing value is a usage error.
0— success. Warnings do not affect the exit code.1— failure: anyerrordiagnostic, an unreadable or missing input file, or a usage error (missing input, unknown flag, or a missing option value).
An unknown flag prints an error: line followed by the usage line; a missing
input argument or a missing option value prints only the usage line. An
unreadable or nonexistent input file prints error: cannot read <file>: <reason> with no usage line. All are written to stderr:
error: unknown argument: --theme
usage: opm2svg <input.opl> [-o out.svg] [--json out.json]
Diagnostics are written to stderr, one per line, as:
<severity>: <code> @<line>:<column> <message>
The parser never throws. Codes currently emitted:
error—reserved-name(a thing is named after a reserved word).warning—unrecognized-sentence,unknown-kind,unknown-reference,process-no-io.
The SVG is written even when diagnostics are present, so you can inspect the
partial render; the exit code still reflects any error.
Given model.opl:
Order is physical.
Handling is physical.
Handling consumes Order.
Handling yields Handled Order.
Convert it to model.svg (the default output path):
npx opm2svg model.oplChoose an explicit output path and also dump the model:
npx opm2svg model.opl -o out/diagram.svg --json out/diagram.jsonWrap it in a script and fail the build on errors:
npx opm2svg model.opl -o model.svg || exit 1- Getting started — install and first render.
- OPL syntax — the supported subset.
- Editor integration — using the CLI for on-save diagnostics.