use crate::common::OutputFormat;
use crate::common_download::download_all_rir_files;
use crate::error::AppError;
use crate::process::process_all_country_codes;
use reqwest::Client;
use crate::common::debug_log;
pub async fn run_country_codes(
country_codes: &[String],
client: &Client,
output_format: OutputFormat,
continue_on_partial: bool,
retry_attempts: u32,
max_backoff_secs: u64,
) -> Result<(), AppError> {
let (rir_texts, failed_urls) =
download_all_rir_files(client, retry_attempts, max_backoff_secs).await?;
if !failed_urls.is_empty() {
debug_log(format!("Some RIR files failed to download: {:?}", failed_urls));
if !continue_on_partial {
return Err(AppError::Other(
"Some RIR downloads failed (use --continue-on-partial to proceed)".into(),
));
}
}
if rir_texts.is_empty() {
return Err(AppError::Other(
"No RIR files available to process".into(),
));
}
process_all_country_codes(country_codes, &rir_texts, output_format).await?;
Ok(())
}