ic-query-cli 0.52.5

Command-line wrapper for read-only Internet Computer metadata queries
Documentation
use super::cache_request;
use crate::progress::StderrQueryProgress;
use crate::{
    cli::common::write_text_or_json,
    nns::{NnsCommandError, now_unix_secs, subnet::options::CatalogInfoOptions},
};
use clap::ArgMatches;
use ic_query::subnet_catalog::{
    DEFAULT_STALE_AFTER_SECONDS, SubnetCatalogInfoRequest,
    build_subnet_catalog_info_report_with_progress, subnet_catalog_info_report_text,
};
pub(super) fn run_catalog_info(matches: &ArgMatches, network: &str) -> Result<(), NnsCommandError> {
    let options = CatalogInfoOptions::from_matches(matches, network);
    let format = options.format;
    let cache = cache_request(&options.network)?;
    let mut request = SubnetCatalogInfoRequest::new(
        cache,
        options.source_endpoint,
        options.input,
        now_unix_secs()?,
        DEFAULT_STALE_AFTER_SECONDS,
    );
    if let Some(forced) = options.forced {
        request = request.with_forced(forced);
    }
    let report =
        build_subnet_catalog_info_report_with_progress(&request, &mut StderrQueryProgress::new())?;
    write_text_or_json(format, &report, subnet_catalog_info_report_text)
}