format

Format Calor source files to canonical style.

Bash
calor format <files...> [options]

Overview

The format command formats Calor source files according to the canonical Calor style guide. This ensures consistent formatting across your codebase.


Quick Start

Bash
# Format a single file (output to stdout)
calor format MyModule.calr

# Format and overwrite the file
calor format MyModule.calr --write

# Check if files are formatted (for CI)
calor format src/*.calr --check

# Show diff of changes
calor format MyModule.calr --diff

Options

OptionShortDefaultDescription
--check-cfalseCheck if files are formatted without modifying (exit 1 if not)
--write-wfalseWrite formatted output back to the file(s)
--diff-dfalseShow diff of formatting changes
--verbose-vfalseEnable verbose output

Formatting Rules

The Calor formatter applies these rules:

  • 2 spaces per indentation level
  • Single space after structure tags
  • Single space around operators in expressions
  • No trailing whitespace
  • One blank line between functions
  • Newline at end of file

Check Mode

Use --check in CI/CD to verify formatting:

Bash
calor format src/*.calr --check

Exit codes:

  • 0 - All files are formatted correctly
  • 1 - One or more files need formatting

Exit Codes

CodeMeaning
0Success
1Unformatted files found (--check mode)
2Error processing files

See Also