ic-query-cli 0.101.0

Command-line wrapper for read-only Internet Computer metadata queries
Documentation
//! Module: nns::node_operator
//!
//! Responsibility: assemble node-operator CLI specification, reports, and dispatch.
//! Does not own: reusable report construction or cache mechanics.
//! Boundary: adapts node-operator arguments to the typed library API.

use crate::nns::{NnsCommandError, leaf};
use crate::presentation::nns::node_operator::nns_node_operator_info_report_text;
use crate::presentation::nns::node_operator::nns_node_operator_list_report_text;
use clap::ArgMatches;
use ic_query::nns::node_operator::build_nns_node_operator_info_report_with_source_and_progress;
use ic_query::nns::node_operator::build_nns_node_operator_list_report_with_source_and_progress;

mod spec;

pub(in crate::nns) fn command() -> clap::Command {
    leaf::command(
        &spec::NODE_OPERATOR_SPEC,
        ic_query::nns::node_operator::DEFAULT_NNS_NODE_OPERATOR_SOURCE_ENDPOINT,
    )
}

pub(in crate::nns) async fn run(
    matches: &ArgMatches,
    network: &str,
) -> Result<(), NnsCommandError> {
    leaf::run_cached_leaf(
        matches,
        network,
        async |request, progress| {
            build_nns_node_operator_list_report_with_source_and_progress(
                request,
                &ic_query::nns::LiveNnsSource::default(),
                progress,
            )
            .await
        },
        async |request, progress| {
            build_nns_node_operator_info_report_with_source_and_progress(
                request,
                &ic_query::nns::LiveNnsSource::default(),
                progress,
            )
            .await
        },
        nns_node_operator_list_report_text,
        nns_node_operator_info_report_text,
    )
    .await
}

#[cfg(test)]
pub(in crate::nns) use spec::NODE_OPERATOR_SPEC;