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
32
33
34
35
36
37
38
39
pub mod get;
pub mod list;
pub mod register;
pub mod zonefile;
use crate::commands::AsyncCliCommand;

/// Manage DNS records
#[derive(clap::Subcommand, Debug)]
pub enum CmdDomain {
    /// List domains
    List(self::list::CmdDomainList),

    /// Get a domain
    Get(self::get::CmdDomainGet),

    /// Get zone file for a domain
    GetZoneFile(self::zonefile::CmdZoneFileGet),

    /// Sync local zone file with remotex
    SyncZoneFile(self::zonefile::CmdZoneFileSync),

    /// Register new domain
    Register(self::register::CmdDomainRegister),
}

#[async_trait::async_trait]
impl AsyncCliCommand for CmdDomain {
    type Output = ();

    async fn run_async(self) -> Result<(), anyhow::Error> {
        match self {
            CmdDomain::List(cmd) => cmd.run_async().await,
            CmdDomain::Get(cmd) => cmd.run_async().await,
            CmdDomain::GetZoneFile(cmd) => cmd.run_async().await,
            CmdDomain::SyncZoneFile(cmd) => cmd.run_async().await,
            CmdDomain::Register(cmd) => cmd.run_async().await,
        }
    }
}