Skip to main content

soroban_cli/commands/container/
mod.rs

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