cli/commands/
mod.rs

1pub mod build_info;
2pub mod internal;
3pub mod misc;
4pub mod node;
5pub mod replay;
6pub mod snark;
7pub mod wallet;
8
9#[derive(Debug, clap::Parser)]
10#[command(name = "mina", about = "Mina Cli")]
11pub struct MinaCli {
12    #[arg(
13        global = true,
14        long,
15        value_enum,
16        default_value_t = Network::Devnet,
17        env = "MINA_NETWORK"
18    )]
19    /// Select the network (devnet or mainnet)
20    pub network: Network,
21
22    #[command(subcommand)]
23    pub command: Command,
24}
25
26#[derive(Debug, Clone, clap::ValueEnum)]
27pub enum Network {
28    Devnet,
29    Mainnet,
30}
31
32#[derive(Debug, clap::Subcommand)]
33#[allow(clippy::large_enum_variant)]
34pub enum Command {
35    /// Mina node.
36    Node(node::Node),
37    Snark(snark::Snark),
38    /// Miscilaneous utilities.
39    Misc(misc::Misc),
40    Replay(replay::Replay),
41    BuildInfo(build_info::Command),
42    /// Wallet operations for managing accounts and sending transactions.
43    Wallet(wallet::Wallet),
44    /// Internal utilities for debugging and introspection.
45    Internal(internal::Internal),
46}
47
48impl Command {
49    pub fn run(self, network: Network) -> anyhow::Result<()> {
50        match self {
51            Self::Snark(v) => v.run(),
52            Self::Node(v) => v.run(),
53            Self::Misc(v) => v.run(),
54            Self::Replay(v) => v.run(),
55            Self::BuildInfo(v) => v.run(),
56            Self::Wallet(v) => v.run(network),
57            Self::Internal(v) => v.run(),
58        }
59    }
60}