ic-query-cli 0.102.0

Command-line wrapper for read-only Internet Computer metadata queries
Documentation
use super::cache_request;
use crate::cli::common::current_unix_secs;
use crate::presentation::subnet_catalog::subnet_catalog_refresh_report_text;
use crate::{
    cli::common::write_text_or_json,
    nns::{NnsCommandError, leaf::NnsLeafRefreshOptions},
};
use clap::ArgMatches;
use ic_query::subnet_catalog::CatalogSourceSelection;
use ic_query::subnet_catalog::SubnetCatalogRefreshRequest;
use ic_query::subnet_catalog::refresh_subnet_catalog;
pub(super) async fn run_catalog_refresh(
    matches: &ArgMatches,
    network: &str,
) -> Result<(), NnsCommandError> {
    let options: NnsLeafRefreshOptions = crate::cli::clap::parsed_options(matches);
    let format = options.common.format();
    let mut request = SubnetCatalogRefreshRequest::new(
        cache_request(network)?,
        CatalogSourceSelection::uncertified_query(options.common.source_endpoint),
        current_unix_secs()?,
    );
    request.dry_run = options.dry_run;

    if let Some(output_path) = options.output_path {
        request.output_path = Some(output_path);
    }
    let report = refresh_subnet_catalog(&request).await?;
    write_text_or_json(format, &report, subnet_catalog_refresh_report_text)
}