refactor(rust): align workspace with style rules
This commit is contained in:
38
src/ariadne/ariadne_main.rs
Normal file
38
src/ariadne/ariadne_main.rs
Normal file
@@ -0,0 +1,38 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user