Architecture¶
Understanding how run works under the hood.
High-Level Overview¶
┌──────────────┐
│ CLI Input │
└──────┬───────┘
│
▼
┌──────────────┐
│ Parser │ Parse args & code
└──────┬───────┘
│
▼
┌──────────────┐
│ Detector │ Detect language
└──────┬───────┘
│
▼
┌──────────────┐
│ Engine │ Select engine
│ Selector │
└──────┬───────┘
│
▼
┌──────────────┐
│ Language │ Execute code
│ Engine │
└──────┬───────┘
│
▼
┌──────────────┐
│ Output │ Return result
└──────────────┘
Components¶
CLI Interface¶
Handles command-line argument parsing using clap.
Language Detector¶
Analyzes code patterns or file extensions to determine the language.
Engine Selector¶
Chooses the appropriate language engine based on detection.
Language Engines¶
Each language has its own engine implementing:
trait LanguageEngine {
fn execute(&self, code: &str) -> Result<Output>;
fn detect(&self, code: &str) -> bool;
fn is_available(&self) -> bool;
}
REPL Manager¶
Maintains session state for interactive mode.
Execution Flow¶
- Parse CLI arguments
- Detect language (if not explicit)
- Check if language toolchain is available
- Create temporary workspace (if needed)
- Execute code through language engine
- Capture and format output
- Clean up temporary files
More Details¶
For complete implementation details, see the source code.