1use anyhow::Result;
2use clap::Parser;
3use std::path::PathBuf;
4
5#[derive(Parser, Debug)]
6pub struct BuildCommand {
7 #[arg(required = true)]
9 pub package_file: PathBuf,
10
11 #[arg(long, required = true)]
13 pub r#type: String,
14
15 #[arg(long, short, num_args = 1.., default_values_t = vec!["current".to_string()])]
18 pub platform: Vec<String>,
19
20 #[arg(long, num_args = 1..)]
22 pub sub: Option<Vec<String>>,
23
24 #[arg(long)]
26 pub sign: Option<String>,
27
28 #[arg(long)]
30 pub test: bool,
31
32 #[arg(long, short = 'o')]
34 pub output_dir: Option<PathBuf>,
35}
36
37pub fn run(args: BuildCommand) -> Result<()> {
38 if args.test {
39 println!("Running tests before building...");
40 crate::pkg::package::test::run(&args)?;
41 println!("Tests passed, proceeding with build...");
42 }
43
44 crate::pkg::package::build::run(
45 &args.package_file,
46 &args.r#type,
47 &args.platform,
48 args.sign,
49 args.output_dir.as_deref(),
50 None,
51 args.sub,
52 false,
53 )
54}