use std::time::Duration;
use anyhow::Result;
use clap::Args;
use crate::client::RommClient;
use super::library_scan::{run_scan_library_flow, ScanCacheInvalidate, ScanLibraryOptions};
use super::OutputFormat;
#[derive(Args, Debug)]
pub struct ScanCommand {
#[arg(long)]
pub wait: bool,
#[arg(long, requires = "wait")]
pub wait_timeout_secs: Option<u64>,
}
pub async fn handle(cmd: ScanCommand, client: &RommClient, format: OutputFormat) -> Result<()> {
let options = ScanLibraryOptions {
wait: cmd.wait,
wait_timeout: Duration::from_secs(cmd.wait_timeout_secs.unwrap_or(3600)),
cache_invalidate: if cmd.wait {
ScanCacheInvalidate::AllPlatforms
} else {
ScanCacheInvalidate::None
},
};
run_scan_library_flow(client, options, format).await
}