cli/commands/
mod.rs

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