harmont_cli/cli/
render.rs1use std::path::PathBuf;
2
3use anyhow::{Context, Result};
4use clap::Parser;
5use hm_dsl_engine::{detect, engine_for};
6
7#[derive(Debug, Clone, Parser)]
8pub struct RenderArgs {
9 #[arg()]
11 pub slug: String,
12
13 #[arg(short, long)]
15 pub dir: Option<PathBuf>,
16}
17
18pub async fn run(args: RenderArgs) -> Result<()> {
29 let repo_root = match args.dir {
30 Some(d) => d,
31 None => std::env::current_dir().context("cannot determine current directory")?,
32 };
33
34 let lang =
35 detect::detect_language_python_first(&repo_root).context("detecting pipeline language")?;
36 let engine = engine_for(lang).context("initializing DSL engine")?;
37 let json = engine
38 .render_pipeline_json(&repo_root, &args.slug)
39 .await
40 .with_context(|| format!("rendering pipeline {:?}", args.slug))?;
41
42 print!("{json}");
44 Ok(())
45}