wasmer-deploy-client-cli 0.1.1

CLI client for Wasmer Deploy
Documentation
pub mod app;
pub mod init;
pub mod namespace;
pub mod publish;
pub mod ssh;

#[derive(clap::Subcommand, Debug)]
pub enum SubCmd {
    #[clap(subcommand)]
    App(app::CmdApp),
    #[clap(subcommand)]
    Namespace(namespace::CmdNamespace),
    #[clap(subcommand)]
    Init(init::CmdInit),
    Publish(publish::CmdAppPublish),

    Ssh(ssh::CmdSsh),
}

impl CliCommand for SubCmd {
    fn run(self) -> Result<(), anyhow::Error> {
        match self {
            Self::Ssh(cmd) => cmd.run(),
            Self::App(cmd) => cmd.run(),
            Self::Namespace(cmd) => cmd.run(),
            Self::Init(cmd) => cmd.run(),
            Self::Publish(cmd) => cmd.run(),
        }
    }
}

pub trait CliCommand {
    fn run(self) -> Result<(), anyhow::Error>;
}

pub trait AsyncCliCommand: Send + Sync + 'static {
    fn run_async(self) -> futures::future::BoxFuture<'static, Result<(), anyhow::Error>>;
}

impl<C: AsyncCliCommand> CliCommand for C {
    fn run(self) -> Result<(), anyhow::Error> {
        tokio::runtime::Runtime::new()?.block_on(self.run_async())
    }
}