mithril_client_cli/commands/cardano_db/
mod.rs

1//! Commands for the Cardano db 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 management (alias: cdb)
15#[derive(Subcommand, Debug, Clone)]
16pub enum CardanoDbCommands {
17    /// Cardano db snapshot commands
18    #[clap(subcommand)]
19    Snapshot(CardanoDbSnapshotCommands),
20
21    /// Download a Cardano db snapshot and verify its associated certificate
22    #[clap(arg_required_else_help = true)]
23    Download(CardanoDbDownloadCommand),
24}
25
26/// Cardano db snapshots
27#[derive(Subcommand, Debug, Clone)]
28pub enum CardanoDbSnapshotCommands {
29    /// List available Cardano db snapshots
30    #[clap(arg_required_else_help = false)]
31    List(CardanoDbListCommand),
32
33    /// Show detailed information about a Cardano db snapshot
34    #[clap(arg_required_else_help = true)]
35    Show(CardanoDbShowCommand),
36}
37
38impl CardanoDbCommands {
39    /// Execute Cardano db command
40    pub async fn execute(&self, config_builder: CommandContext) -> MithrilResult<()> {
41        match self {
42            Self::Download(cmd) => cmd.execute(config_builder).await,
43            Self::Snapshot(cmd) => cmd.execute(config_builder).await,
44        }
45    }
46}
47
48impl CardanoDbSnapshotCommands {
49    /// Execute Cardano db snapshot command
50    pub async fn execute(&self, config_builder: CommandContext) -> MithrilResult<()> {
51        match self {
52            Self::List(cmd) => cmd.execute(config_builder).await,
53            Self::Show(cmd) => cmd.execute(config_builder).await,
54        }
55    }
56}