mithril_client_cli/commands/tools/
mod.rs

1//! Tools commands
2//!
3//! Provides utility subcommands such as converting restored InMemory UTxO-HD ledger snapshot
4//! to different flavors (Legacy, LMDB).
5
6mod snapshot_converter;
7
8pub use snapshot_converter::*;
9
10use anyhow::anyhow;
11use clap::Subcommand;
12use mithril_client::MithrilResult;
13
14/// Tools commands
15#[derive(Subcommand, Debug, Clone)]
16#[command(about = "[unstable] Tools commands")]
17pub enum ToolsCommands {
18    /// UTxO-HD related commands
19    #[clap(subcommand, name = "utxo-hd")]
20    UTxOHD(UTxOHDCommands),
21}
22
23impl ToolsCommands {
24    /// Execute Tools command
25    pub async fn execute(&self) -> MithrilResult<()> {
26        match self {
27            Self::UTxOHD(cmd) => cmd.execute().await,
28        }
29    }
30}
31
32/// UTxO-HD related commands
33#[derive(Subcommand, Debug, Clone)]
34pub enum UTxOHDCommands {
35    /// Convert a restored `InMemory` ledger snapshot to another flavor.
36    #[clap(arg_required_else_help = false)]
37    SnapshotConverter(SnapshotConverterCommand),
38}
39
40impl UTxOHDCommands {
41    /// Execute UTxO-HD command
42    pub async fn execute(&self) -> MithrilResult<()> {
43        match self {
44            Self::SnapshotConverter(cmd) => {
45                if cfg!(target_os = "linux") && cfg!(target_arch = "aarch64") {
46                    return Err(anyhow!(
47                        "'snapshot-converter' command is not supported on Linux ARM"
48                    ));
49                }
50                cmd.execute().await
51            }
52        }
53    }
54}