helix/dna/cmd/
compile.rs

1use clap::Args;
2use std::path::PathBuf;
3use crate::mds::compile::compile_command;
4
5
6#[derive(Args)]
7pub struct CompileArgs {
8    #[arg(short, long)]
9    input: Option<PathBuf>,
10
11    #[arg(short, long)]
12    output: Option<PathBuf>,
13
14    #[arg(short, long)]
15    compress: bool,
16
17    #[arg(short = 'O', long, default_value = "2")]
18    optimize: u8,
19
20    #[arg(long)]
21    cache: bool,
22
23    #[arg(short, long)]
24    verbose: bool,
25
26    #[arg(short, long)]
27    quiet: bool,
28}
29
30pub fn run(args: CompileArgs) -> anyhow::Result<()> {
31    let input = args.input.unwrap_or_else(|| PathBuf::from("."));
32    let output = args.output;
33    let compress = args.compress;
34    let optimize = args.optimize;
35    let cache = args.cache;
36    compile_command(input, output, compress, optimize, cache, args.verbose, args.quiet)
37        .map_err(|e| anyhow::anyhow!("Compilation failed: {}", e))?;
38    println!("Compilation completed");
39
40    Ok(())
41}