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 --diffOptions
| Option | Short | Default | Description |
|---|---|---|---|
--check | -c | false | Check if files are formatted without modifying (exit 1 if not) |
--write | -w | false | Write formatted output back to the file(s) |
--diff | -d | false | Show diff of formatting changes |
--verbose | -v | false | Enable 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 --checkExit codes:
0- All files are formatted correctly1- One or more files need formatting
Exit Codes
| Code | Meaning |
|---|---|
0 | Success |
1 | Unformatted files found (--check mode) |
2 | Error processing files |
See Also
- calor diagnose - Check for errors and warnings
- calor compile - Compile Calor to C#