Code Formatter (`spc fmt`)
SP features an opinionated, built-in code formatter that enforces uniform style across codebases.
bash
1# Check formatting without modifying files (returns non-zero if diff exists)2spc fmt src/ --check34# Format files in-place5spc fmt src/ --write67# Custom 4-space indent8spc fmt src/ --write --indent 4
Formatting Guarantees
- Strict Idempotency: Applying the formatter repeatedly produces the identical AST and text layout:
fmt(fmt(x)) == fmt(x). - Preserves Comments: All single-line
//comments, multi-line blocks, and///docstrings are preserved. - CI Ready: The
--checkflag is suited for GitHub Actions and pre-commit hooks.