mod api_boundary_node;
mod canister;
mod metrics;
mod network;
mod replica_version;
use crate::cli::{clap::parsed_options, common::CurrentUnixSecsError};
use clap::{ArgMatches, Command as ClapCommand, Subcommand};
use ic_query::ic::IcApiBoundaryNodeHostError;
use ic_query::ic::IcHostError;
use std::io;
use thiserror::Error as ThisError;
#[derive(Debug, ThisError)]
pub enum IcCommandError {
#[error("{0}")]
Usage(String),
#[error(transparent)]
Host(#[from] IcHostError),
#[error(transparent)]
CertifiedState(#[from] IcApiBoundaryNodeHostError),
#[error(transparent)]
Clock(#[from] CurrentUnixSecsError),
#[error(transparent)]
Io(#[from] io::Error),
#[error(transparent)]
Json(#[from] serde_json::Error),
}
pub async fn run_matches(matches: &ArgMatches) -> Result<(), IcCommandError> {
match parsed_options::<IcCommand>(matches) {
IcCommand::ApiBoundaryNode(command) => api_boundary_node::run(command).await,
IcCommand::Canister(command) => canister::run(command).await,
IcCommand::Metrics(options) => metrics::run(options).await,
IcCommand::Network(command) => network::run(command).await,
IcCommand::ReplicaVersion(command) => replica_version::run(command).await,
}
}
pub fn command() -> ClapCommand {
IcCommand::augment_subcommands(ClapCommand::new("ic"))
}
#[derive(Subcommand)]
#[command(about = "Inspect certified IC state and official Dashboard data", long_about = None)]
enum IcCommand {
#[command(subcommand)]
ApiBoundaryNode(api_boundary_node::ApiBoundaryNodeCommand),
#[command(subcommand)]
Canister(canister::CanisterCommand),
Metrics(metrics::MetricOptions),
#[command(subcommand)]
Network(network::NetworkCommand),
#[command(subcommand)]
ReplicaVersion(replica_version::ReplicaVersionCommand),
}
#[cfg(test)]
mod tests;