mithril_client_cli/commands/cardano_db_v2/
mod.rs

1//! Commands for the Cardano db v2 artifact
2mod download;
3mod list;
4mod show;
5
6pub use download::*;
7pub use list::*;
8pub use show::*;
9
10use crate::CommandContext;
11use clap::Subcommand;
12use mithril_client::MithrilResult;
13
14/// Cardano db v2 management (alias: cdbv2)
15#[derive(Subcommand, Debug, Clone)]
16#[command(about = "[unstable] Cardano db v2 management (alias: cdbv2)")]
17pub enum CardanoDbV2Commands {
18    /// Cardano db snapshot v2 commands
19    #[clap(subcommand)]
20    Snapshot(CardanoDbV2SnapshotCommands),
21
22    /// Download a Cardano db v2 snapshot to restore a partial Cardano database.
23    #[clap(arg_required_else_help = true)]
24    Download(CardanoDbV2DownloadCommand),
25}
26
27/// Cardano db v2 snapshots
28#[derive(Subcommand, Debug, Clone)]
29pub enum CardanoDbV2SnapshotCommands {
30    /// List available Cardano db v2 snapshots
31    #[clap(arg_required_else_help = false)]
32    List(CardanoDbListCommand),
33
34    /// Show detailed information about a Cardano db v2 snapshot
35    #[clap(arg_required_else_help = true)]
36    Show(CardanoDbShowCommand),
37}
38
39impl CardanoDbV2Commands {
40    /// Execute Cardano db v2 command
41    pub async fn execute(&self, config_builder: CommandContext) -> MithrilResult<()> {
42        match self {
43            Self::Snapshot(cmd) => cmd.execute(config_builder).await,
44            Self::Download(cmd) => cmd.execute(config_builder).await,
45        }
46    }
47}
48
49impl CardanoDbV2SnapshotCommands {
50    /// Execute Cardano db v2 snapshot command
51    pub async fn execute(&self, config_builder: CommandContext) -> MithrilResult<()> {
52        match self {
53            Self::List(cmd) => cmd.execute(config_builder).await,
54            Self::Show(cmd) => cmd.execute(config_builder).await,
55        }
56    }
57}