relay-cli 0.1.2

CLI interface for Relay Agents.
mod claim;
mod claim_inbox;
mod identities;
mod identity;
mod messages;
mod read;
mod send;
mod wipeout;

use anyhow::Result;
use clap::Subcommand;

use crate::{args::Args, storage::Storage};

#[derive(Debug, Clone, Subcommand)]
pub enum Cmd {
    Claim(claim::ClaimCmd),
    ClaimInbox(claim_inbox::ClaimInboxCmd),
    Identities(identities::IdentitiesCmd),
    Identity(identity::IdentityCmd),
    Messages(messages::MessagesCmd),
    Read(read::ReadCmd),
    Send(send::SendCmd),
    Wipeout(wipeout::WipeoutCmd),
}

impl Cmd {
    pub fn execute(&self, args: Args, storage: &mut Storage) -> Result<()> {
        match self {
            Self::Claim(cmd) => cmd.execute(args, storage)?,
            Self::ClaimInbox(cmd) => cmd.execute(args, storage)?,
            Self::Identities(cmd) => cmd.execute(storage)?,
            Self::Identity(cmd) => cmd.execute(storage)?,
            Self::Messages(cmd) => cmd.execute(args, storage)?,
            Self::Read(cmd) => cmd.execute(args, storage)?,
            Self::Send(cmd) => cmd.execute(args, storage)?,
            Self::Wipeout(cmd) => cmd.execute(storage)?,
        }

        Ok(())
    }
}