diff --git a/src/commands/scan.rs b/src/commands/scan.rs index d5a71a9..d93dd7b 100644 --- a/src/commands/scan.rs +++ b/src/commands/scan.rs @@ -134,7 +134,17 @@ pub async fn run_report( } /// Download the SBOM. -pub async fn run_sbom(client: &AnalyzerClient, scan_id: Uuid, output_path: PathBuf) -> Result<()> { +pub async fn run_sbom( + client: &AnalyzerClient, + scan_id: Uuid, + output_path: PathBuf, + wait: bool, + interval: Duration, + timeout: Duration, +) -> Result<()> { + if wait { + wait_for_completion(client, scan_id, interval, timeout).await?; + } output::status("Downloading", "SBOM..."); let bytes = client.download_sbom(scan_id).await?; tokio::fs::write(&output_path, &bytes).await?; diff --git a/src/main.rs b/src/main.rs index 5f770d6..a3ea2d3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -242,6 +242,18 @@ enum ScanCommand { /// Output file path. #[arg(short = 'O', long)] output: PathBuf, + + /// Wait for scan completion first. + #[arg(short, long)] + wait: bool, + + /// Poll interval when waiting. + #[arg(long, value_parser = humantime::parse_duration, default_value = "2s")] + interval: Duration, + + /// Maximum wait time. + #[arg(long, value_parser = humantime::parse_duration, default_value = "10m")] + timeout: Duration, }, /// Download a compliance report (PDF). @@ -435,9 +447,12 @@ async fn run(cli: Cli) -> Result<()> { scan_id, object_id, output, + wait, + interval, + timeout, } => { let sid = commands::scan::resolve_scan_id(&client, scan_id, object_id).await?; - commands::scan::run_sbom(&client, sid, output).await + commands::scan::run_sbom(&client, sid, output, wait, interval, timeout).await } ScanCommand::ComplianceReport { scan_id,