scrii_fmt — source formatter
scrii_fmt is a standalone source-code formatter for Scrii. It reads Scrii
source and rewrites it into a canonical style — indentation, spacing,
line-wrapping, and object-literal formatting — so that code written by
different people looks the same.
Build
From the repository root (as part of the full build):
cmake --build build --target scrii_fmt
Or standalone — the formatter builds its own copy of the core library:
cmake -S formatter -B formatter/build
cmake --build formatter/build
Usage
scrii_fmt # format stdin -> stdout
scrii_fmt file.scr # format in place
scrii_fmt -c file.scr # check mode: exit 1 if changes needed
scrii_fmt -w 100 file.scr # max line width (default 88)
scrii_fmt -i 4 file.scr # indent width (default 2)
scrii_fmt -h / --help # help
Common workflows:
- Format a file in place:
scrii_fmt path/to/file.scr - CI check:
scrii_fmt -c src/— exit code1when changes are needed, so it can gate merges. - Pipe through stdin/stdout:
scrii_fmt < in.scr > out.scr
Behavior
- Never splits string literals. Long lines wrap at spaces with a continuation indent proportional to the configured indent width.
- Object literals expand onto multiple lines when they exceed the line width;
block braces (
if,for, ...) never expand. - Ternary colons and method-call colons are formatted distinctly from object
key/value separators, so
cond ? a : b,x:foo(), and{k: v}are all handled correctly. - Formatting is idempotent: it iterates to a fixed point, so running it twice is the same as running it once.
Editor integration
The formatter is a plain command-line tool, so wire it into any editor as an external formatter.