1use std::path::PathBuf;
2
3use dmc_diagnostic::Code;
4use duck_diagnostic::DiagnosticEngine;
5
6use crate::engine::compile::Compiler;
7
8#[derive(clap::Args)]
9pub struct CompileCmd {
10 #[arg(long, default_value = "dmc.toml")]
11 pub path: PathBuf,
12}
13
14impl CompileCmd {
15 pub fn run(self) -> std::io::Result<()> {
18 let mut diag_engine = DiagnosticEngine::<Code>::new();
19
20 let src = std::fs::read_to_string(&self.path)?;
21 let out = Compiler::compile(&src, &mut diag_engine);
22 let json = serde_json::to_string_pretty(&out).unwrap();
23 println!("{}", json);
24 Ok(())
25 }
26}