helix/dna/cmd/
bundle.rs

1use clap::Args;
2use std::path::PathBuf;
3
4#[derive(Args)]
5pub struct BundleArgs {
6    directory: PathBuf,
7    /// Target directory to analyze (defaults to current directory)
8    #[arg(short, long)]
9    input: Option<PathBuf>,
10
11    /// Output file path (defaults to stdout if not specified)
12    #[arg(short, long)]
13    output: Option<PathBuf>,
14
15    /// Include files (defaults to all files)
16    #[arg(short, long)]
17    include: Vec<String>,
18
19    /// Exclude files (defaults to none)
20    #[arg(short = 'x', long)]
21    exclude: Vec<String>,
22
23    /// Tree shake (defaults to false)
24    #[arg(long)]
25    tree_shake: bool,
26
27    /// Optimize (defaults to 2)
28    #[arg(short = 'O', long, default_value = "2")]
29    optimize: u8,
30
31    
32
33}
34
35pub fn run(args: BundleArgs) -> anyhow::Result<()> {
36    let input = args.input.unwrap_or_else(|| PathBuf::from("."));
37    let output = args.output.unwrap_or_else(|| PathBuf::from("bundle.hlxb"));
38    let include = args.include;
39    let exclude = args.exclude;
40    let tree_shake = args.tree_shake;
41    let optimize = args.optimize;
42    crate::dna::mds::bundle::bundle_command(input, output, include, exclude, tree_shake, optimize, false)
43        .map_err(|e| anyhow::anyhow!("Bundle command failed: {}", e))?;
44    Ok(())
45}