ic-query-cli 0.104.1

Command-line wrapper for read-only Internet Computer metadata queries
Documentation
//! Typed Clap command tree for direct NNS Governance reports.

use crate::cli::common::{COLLECTION_MODE_LIVE, SourceOutputOptions, collection_help};
use clap::{Command as ClapCommand, Subcommand};
use ic_query::nns::governance::DEFAULT_NNS_GOVERNANCE_SOURCE_ENDPOINT;

const GOVERNANCE_HELP_AFTER: &str = "\
Examples:
  icq nns governance economics
  icq nns governance metrics
  icq nns governance reward-event
  icq nns governance maturity-modulation";

const ECONOMICS_HELP_AFTER: &str = "\
Examples:
  icq nns governance economics
  icq nns governance economics --json";

const METRICS_HELP_AFTER: &str = "\
Examples:
  icq nns governance metrics
  icq nns governance metrics --json";

const REWARD_EVENT_HELP_AFTER: &str = "\
Examples:
  icq nns governance reward-event
  icq nns governance reward-event --json";

const MATURITY_MODULATION_HELP_AFTER: &str = "\
Examples:
  icq nns governance maturity-modulation
  icq nns governance maturity-modulation --json";

///
/// GovernanceCommand
///
/// Parsed operation and arguments for direct NNS Governance reports.
///

#[derive(Subcommand)]
#[command(about = "Inspect NNS Governance economics, metrics, and rewards", long_about = None, after_help = GOVERNANCE_HELP_AFTER)]
pub(super) enum GovernanceCommand {
    #[command(about = "Show NNS Governance network economics parameters", long_about = None, after_help = collection_help(COLLECTION_MODE_LIVE, ECONOMICS_HELP_AFTER))]
    Economics(SourceOutputOptions),
    #[command(about = "Show cached NNS Governance metrics", long_about = None, after_help = collection_help(COLLECTION_MODE_LIVE, METRICS_HELP_AFTER))]
    Metrics(SourceOutputOptions),
    #[command(about = "Show the latest NNS Governance voting reward event", long_about = None, after_help = collection_help(COLLECTION_MODE_LIVE, REWARD_EVENT_HELP_AFTER))]
    RewardEvent(SourceOutputOptions),
    #[command(about = "Show current NNS Governance maturity modulation", long_about = None, after_help = collection_help(COLLECTION_MODE_LIVE, MATURITY_MODULATION_HELP_AFTER))]
    MaturityModulation(SourceOutputOptions),
}

pub(in crate::nns) fn governance_command() -> ClapCommand {
    GovernanceCommand::augment_subcommands(ClapCommand::new("governance")).mut_subcommands(
        |command| {
            command.mut_arg("source-endpoint", |arg| {
                arg.default_value(DEFAULT_NNS_GOVERNANCE_SOURCE_ENDPOINT)
                    .help("IC API endpoint used for the native NNS Governance query")
            })
        },
    )
}