use std::path::PathBuf;
use anyhow::{Context, Result};
use clap::Parser;
use hm_dsl_engine::{detect, engine_for};
#[derive(Debug, Clone, Parser)]
pub struct RenderArgs {
#[arg()]
pub slug: String,
#[arg(short, long)]
pub dir: Option<PathBuf>,
}
pub async fn run(args: RenderArgs) -> Result<()> {
let repo_root = match args.dir {
Some(d) => d,
None => std::env::current_dir().context("cannot determine current directory")?,
};
let lang =
detect::detect_language_python_first(&repo_root).context("detecting pipeline language")?;
let engine = engine_for(lang).context("initializing DSL engine")?;
let json = engine
.render_pipeline_json(&repo_root, &args.slug)
.await
.with_context(|| format!("rendering pipeline {:?}", args.slug))?;
print!("{json}");
Ok(())
}