soroban_cli/commands/container/mod.rs
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 40 41 42 43 44 45 46 47 48 49 50
use crate::commands::global;
pub(crate) mod logs;
mod shared;
pub(crate) mod start;
pub(crate) mod stop;
// TODO: remove once `network start` is removed
pub type StartCmd = start::Cmd;
// TODO: remove once `network top` is removed
pub type StopCmd = stop::Cmd;
#[derive(Debug, clap::Subcommand)]
pub enum Cmd {
    /// Get logs from a running network container
    Logs(logs::Cmd),
    /// Start a container running a Stellar node, RPC, API, and friendbot (faucet).
    ///
    /// `stellar container start NETWORK [OPTIONS]`
    ///
    /// By default, when starting a testnet container, without any optional arguments, it will run the equivalent of the following docker command:
    ///
    /// `docker run --rm -p 8000:8000 --name stellar stellar/quickstart:testing --testnet --enable rpc,horizon`
    Start(start::Cmd),
    /// Stop a network container started with `stellar container start`.
    Stop(stop::Cmd),
}
#[derive(thiserror::Error, Debug)]
pub enum Error {
    #[error(transparent)]
    Logs(#[from] logs::Error),
    #[error(transparent)]
    Start(#[from] start::Error),
    #[error(transparent)]
    Stop(#[from] stop::Error),
}
impl Cmd {
    pub async fn run(&self, global_args: &global::Args) -> Result<(), Error> {
        match &self {
            Cmd::Logs(cmd) => cmd.run(global_args).await?,
            Cmd::Start(cmd) => cmd.run(global_args).await?,
            Cmd::Stop(cmd) => cmd.run(global_args).await?,
        }
        Ok(())
    }
}