//! The `navdata_sync` / `navdata_status` tools: device-store upkeep.

use chrono::Utc;

use crate::error::ToolError;

/// Bring the device navdata store current from its subscriptions;
/// returns the human-readable sync report.
pub async fn sync_store() -> Result<String, ToolError> {
    let store = aerocontext_navdata::sync::default_store();
    let today = Utc::now().date_naive();
    Ok(aerocontext_navdata::cli::sync(None, &store, None, false, today, crate::USER_AGENT).await?)
}

/// Subscriptions, store contents, and cycle tracking at a glance.
pub async fn store_status() -> Result<String, ToolError> {
    let store = aerocontext_navdata::sync::default_store();
    let today = Utc::now().date_naive();
    Ok(aerocontext_navdata::cli::status(None, &store, today).await?)
}
