Skip to main content

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    /// Override the package version
24    #[arg(long)]
25    pub version_override: Option<String>,
26
27    /// The build type to bundle (e.g. 'source', 'pre-compiled')
28    #[arg(long, short = 't')]
29    pub build_type: Option<String>
30}
31
32/// Runs the `package bundle` command.
33///
34/// # Errors
35///
36/// Returns an error if the package cannot be bundled, if there are missing
37/// dependencies, or if there is an error writing the bundle file.
38pub fn run(args: BundleCommand) -> Result<()> {
39    crate::pkg::package::bundle::run(
40        &args.package_file,
41        args.output_dir.as_deref(),
42        args.sign,
43        args.version_override.as_deref(),
44        args.build_type.as_deref()
45    )
46}