mithril_client_cli/commands/cardano_db/
mod.rs1mod download;
3mod list;
4mod shared_steps;
5mod show;
6mod verify;
7
8pub use download::*;
9pub use list::*;
10pub use show::*;
11pub use verify::*;
12
13use crate::CommandContext;
14use clap::{Subcommand, ValueEnum};
15use mithril_client::MithrilResult;
16
17#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Default, ValueEnum)]
19pub enum CardanoDbCommandsBackend {
20 #[default]
22 #[clap(help = "[default] Legacy backend, full database restoration only")]
23 V1,
24 #[clap(help = "[unstable] V2 backend, full or partial database restoration")]
26 V2,
27}
28
29#[derive(Subcommand, Debug, Clone)]
31pub enum CardanoDbCommands {
32 #[clap(subcommand)]
34 Snapshot(CardanoDbSnapshotCommands),
35
36 #[clap(arg_required_else_help = true)]
38 Download(CardanoDbDownloadCommand),
39
40 #[clap(arg_required_else_help = true)]
42 Verify(CardanoDbVerifyCommand),
43}
44
45#[derive(Subcommand, Debug, Clone)]
47pub enum CardanoDbSnapshotCommands {
48 #[clap(arg_required_else_help = false)]
50 List(CardanoDbListCommand),
51
52 #[clap(arg_required_else_help = true)]
54 Show(CardanoDbShowCommand),
55}
56
57impl CardanoDbCommands {
58 pub async fn execute(&self, config_builder: CommandContext) -> MithrilResult<()> {
60 match self {
61 Self::Download(cmd) => cmd.execute(config_builder).await,
62 Self::Snapshot(cmd) => cmd.execute(config_builder).await,
63 Self::Verify(cmd) => cmd.execute(config_builder).await,
64 }
65 }
66}
67
68impl CardanoDbSnapshotCommands {
69 pub async fn execute(&self, config_builder: CommandContext) -> MithrilResult<()> {
71 match self {
72 Self::List(cmd) => cmd.execute(config_builder).await,
73 Self::Show(cmd) => cmd.execute(config_builder).await,
74 }
75 }
76}