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 .cs files to Calor syntax
  • Calor → C#: Convert .calr files 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 --benchmark

Options

OptionShortDefaultDescription
--output-oAuto-detectedOutput file path
--benchmark-bfalseInclude benchmark metrics comparison
--verbose-vfalseEnable verbose output

Auto-Detected Output Paths

If --output is not specified:

InputOutput
MyFile.csMyFile.calr
MyFile.calrMyFile.g.cs

Supported Constructs

C# ConstructCalor 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 --benchmark

Output:

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

CodeMeaning
0Conversion successful
1Conversion completed with warnings
2Error - file not found, parse error, etc.

See Also