convert
Convert a single file between C# and Calor.
Bash
calor convert <input> [options]Overview
The convert command performs bidirectional conversion between C# and Calor:
- C# → Calor: Convert
.csfiles to Calor syntax - Calor → C#: Convert
.calrfiles to generated C#
The conversion direction is automatically detected from the input file extension.
Quick Start
Bash
# Convert C# to Calor
calor convert MyService.cs
# Convert Calor to C#
calor convert MyService.calr
# Specify output path
calor convert MyService.cs --output src/MyService.calr
# Include benchmark comparison
calor convert MyService.cs --benchmarkOptions
| Option | Short | Default | Description |
|---|---|---|---|
--output | -o | Auto-detected | Output file path |
--benchmark | -b | false | Include benchmark metrics comparison |
--verbose | -v | false | Enable verbose output |
Auto-Detected Output Paths
If --output is not specified:
| Input | Output |
|---|---|
MyFile.cs | MyFile.calr |
MyFile.calr | MyFile.g.cs |
Supported Constructs
| C# Construct | Calor Equivalent |
|---|---|
namespace | §M{id:Name} module |
class | §CL{id:Name:vis} class |
method | §F{id:Name:vis} function |
property | §PROP{id:Name:vis:type} property |
field | §FLD{id:type:name} field |
if/else if/else | §IF{id}...§EI...§EL...§/I{id} |
for loop | §L{id:var:from:to:step} |
while loop | §WH{id} |
Benchmark Comparison
Use --benchmark to see how the Calor version compares to C#:
Bash
calor convert PaymentService.cs --benchmarkOutput:
Plain Text
Benchmark Comparison:
┌─────────────────┬────────┬────────┬──────────┐
│ Metric │ C# │ Calor │ Savings │
├─────────────────┼────────┼────────┼──────────┤
│ Tokens │ 1,245 │ 842 │ 32.4% │
│ Lines │ 156 │ 98 │ 37.2% │
│ Characters │ 4,521 │ 2,891 │ 36.1% │
└─────────────────┴────────┴────────┴──────────┘Exit Codes
| Code | Meaning |
|---|---|
0 | Conversion successful |
1 | Conversion completed with warnings |
2 | Error - file not found, parse error, etc. |
See Also
- calor migrate - Convert entire projects
- calor analyze - Find best conversion candidates
- calor benchmark - Detailed metrics comparison