soroban_cli/commands/container/
mod.rs

1use crate::commands::global;
2
3pub(crate) mod logs;
4mod shared;
5pub(crate) mod start;
6pub(crate) mod stop;
7
8// TODO: remove once `network start` is removed
9pub type StartCmd = start::Cmd;
10// TODO: remove once `network top` is removed
11pub type StopCmd = stop::Cmd;
12
13#[derive(Debug, clap::Subcommand)]
14pub enum Cmd {
15    /// Get logs from a running network container
16    Logs(logs::Cmd),
17    /// Start a container running a Stellar node, RPC, API, and friendbot (faucet).
18    ///
19    /// `stellar container start NETWORK [OPTIONS]`
20    ///
21    /// By default, when starting a testnet container, without any optional arguments, it will run the equivalent of the following docker command:
22    ///
23    /// `docker run --rm -p 8000:8000 --name stellar stellar/quickstart:testing --testnet --enable rpc,horizon`
24    Start(start::Cmd),
25    /// Stop a network container started with `stellar container start`.
26    Stop(stop::Cmd),
27}
28
29#[derive(thiserror::Error, Debug)]
30pub enum Error {
31    #[error(transparent)]
32    Logs(#[from] logs::Error),
33
34    #[error(transparent)]
35    Start(#[from] start::Error),
36
37    #[error(transparent)]
38    Stop(#[from] stop::Error),
39}
40
41impl Cmd {
42    pub async fn run(&self, global_args: &global::Args) -> Result<(), Error> {
43        match &self {
44            Cmd::Logs(cmd) => cmd.run(global_args).await?,
45            Cmd::Start(cmd) => cmd.run(global_args).await?,
46            Cmd::Stop(cmd) => cmd.run(global_args).await?,
47        }
48        Ok(())
49    }
50}