use std::{path::Path, process::ExitCode};
use anyhow::Result;
use clap::Parser;
use dalbit_core::{manifest::Manifest, transpile};
use std::time::Instant;
use dalbit_core::manifest::DEFAULT_MANIFEST_PATH;
#[derive(Debug, Clone, Parser)]
pub struct TranspileCommand {
#[arg(long, default_value = DEFAULT_MANIFEST_PATH)]
config: String,
}
impl TranspileCommand {
pub async fn run(self) -> Result<ExitCode> {
let config_path = Path::new(&self.config);
let process_start_time = Instant::now();
let manifest = Manifest::from_file(config_path).await?;
transpile::process(manifest).await?;
let process_duration = durationfmt::to_string(process_start_time.elapsed());
println!("Successfully transpiled in {}", process_duration);
return Ok(ExitCode::SUCCESS);
}
}