1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use component_state::state::StateOptions;

use crate::bridge::DarwiniaEthereumTask;
use crate::command::handler;
use crate::Opts;

/// Execute command
pub async fn execute(opts: Opts) -> color_eyre::Result<()> {
    match opts {
        Opts::Start => handler::handle_start().await,
        Opts::Affirm { command } => handler::handle_affirm(command).await,
        Opts::Confirm { command } => handler::handle_confirm(command).await,
        Opts::Ecdsa { command } => handler::handle_ecdsa(command).await,
        Opts::Guard => handler::handle_guard().await,
        Opts::Info { command } => handler::handle_info(command).await,
        Opts::Keys => handler::handle_keys().await,
        Opts::Mmr { command } => handler::handle_mmr(command).await,
        Opts::Parcel { command, output } => handler::handle_parcel(command, output).await,
        Opts::Relay { command } => handler::handle_relay(command).await,
        Opts::Kv { command } => {
            let task_name = DarwiniaEthereumTask::name();
            let namespace = command.namespace.unwrap_or_else(|| task_name.to_string());
            let state_options = StateOptions {
                db_name: task_name.to_string(),
            };
            support_command_kv::handle_kv(state_options, Some(namespace), command.command)
        }
    }
}