zoi_cli/cmd/package/bundle.rs
1//! Implementation of the `package bundle` command.
2
3use std::path::PathBuf;
4
5use anyhow::Result;
6use clap::Parser;
7
8/// Arguments for the `package bundle` command.
9#[derive(Parser, Debug)]
10pub struct BundleCommand {
11 /// Path to the package file (e.g. path/to/name.pkg.lua)
12 #[arg(required = true)]
13 pub package_file: PathBuf,
14
15 /// Directory to output the bundled package to
16 #[arg(long, short = 'o')]
17 pub output_dir: Option<PathBuf>,
18
19 /// Sign the bundle with a PGP key
20 #[arg(long)]
21 pub sign: Option<String>,
22
23 /// How to attach the signature when --sign is used. `embed` stores the
24 /// signature inside the bundle; `file` writes a legacy `.sig` sidecar.
25 #[arg(long, value_enum, default_value_t = super::build::SignModeArg::Embed)]
26 pub sign_mode: super::build::SignModeArg,
27
28 /// Override the package version
29 #[arg(long)]
30 pub version_override: Option<String>,
31
32 /// The build type to bundle (e.g. 'source', 'pre-compiled')
33 #[arg(long, short = 't')]
34 pub build_type: Option<String>
35}
36
37/// Runs the `package bundle` command.
38///
39/// # Errors
40///
41/// Returns an error if the package cannot be bundled, if there are missing
42/// dependencies, or if there is an error writing the bundle file.
43pub fn run(args: BundleCommand) -> Result<()> {
44 crate::pkg::package::bundle::run(
45 &args.package_file,
46 args.output_dir.as_deref(),
47 args.sign,
48 args.sign_mode.into(),
49 args.version_override.as_deref(),
50 args.build_type.as_deref()
51 )?;
52 Ok(())
53}