Files
dev/src/ariadne/ariadne_main.rs

39 lines
942 B
Rust

use std::path::PathBuf;
use clap::Parser;
#[derive(Debug, Parser)]
struct Args {
#[arg(long, default_value = "output")]
output_dir: PathBuf,
#[arg(long)]
force: bool,
#[arg(default_value = "all", value_parser = parse_stage)]
target_stage: ariadne::pipeline::Stage,
}
impl From<Args> for ariadne::Config {
fn from(args: Args) -> Self {
ariadne::Config {
output_dir: monorepo::workspace::resolve_workspace_path(args.output_dir),
force: args.force,
target_stage: args.target_stage,
}
}
}
fn parse_stage(value: &str) -> Result<ariadne::pipeline::Stage, String> {
ariadne::pipeline::Stage::ALL
.iter()
.copied()
.find(|stage| stage.name() == value)
.ok_or_else(|| format!("unknown stage: {value}"))
}
fn main() -> ariadne::Result<()> {
let config: ariadne::Config = Args::parse().into();
ariadne::run(&config)
}