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
30
31
use crate::mjolnir_lib::MjolnirError;
use clap::Parser;
use thiserror::Error;

mod batch;
mod standard;

#[derive(Parser, Debug)]
pub enum FragmentLoadCommand {
    /// sends fragments using batch endpoint
    #[clap(subcommand)]
    Batch(batch::Batch),
    /// sends fragments in single manner
    #[clap(subcommand)]
    Standard(standard::Standard),
}

#[derive(Error, Debug)]
pub enum FragmentLoadCommandError {
    #[error("Client Error")]
    ClientError(#[from] MjolnirError),
}

impl FragmentLoadCommand {
    pub fn exec(&self) -> Result<(), MjolnirError> {
        match self {
            FragmentLoadCommand::Batch(batch) => batch.exec(),
            FragmentLoadCommand::Standard(standard) => standard.exec(),
        }
    }
}