Skip to main content

greentic_bundle/cli/
export.rs

1use std::path::PathBuf;
2
3use anyhow::Result;
4use clap::Args;
5
6use crate::cli::build::SigningArgs;
7
8#[derive(Debug, Args)]
9pub struct ExportArgs {
10    #[arg(long, value_name = "DIR", help = "cli.export.build_dir.option")]
11    pub build_dir: PathBuf,
12
13    #[arg(long, value_name = "FILE", help = "cli.export.output.option")]
14    pub output: PathBuf,
15
16    #[arg(long, default_value_t = false, help = "cli.option.dry_run")]
17    pub dry_run: bool,
18
19    /// Embed a precompiled component cache (`.cache/v1/...`) into the bundle.
20    /// Requires `greentic-start` on PATH.
21    #[arg(long, default_value_t = false)]
22    pub warmup: bool,
23
24    #[command(flatten)]
25    pub signing: SigningArgs,
26}
27
28pub fn run(args: ExportArgs) -> Result<()> {
29    let signing = args.signing.to_config();
30    let result = crate::build::export_build_dir(
31        &args.build_dir,
32        &args.output,
33        args.dry_run,
34        args.warmup,
35        signing.as_ref(),
36    )?;
37    println!("{}", serde_json::to_string_pretty(&result)?);
38    Ok(())
39}