Skip to content

Commit

Permalink
Move container command to root (#1710)
Browse files Browse the repository at this point in the history
  • Loading branch information
leighmcculloch authored Nov 7, 2024
1 parent 11e08ef commit 8e1d45b
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 21 deletions.
93 changes: 87 additions & 6 deletions FULL_HELP_DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ Anything after the `--` double dash (the "slop") is parsed as arguments to the c
* `events` — Watch the network for contract events
* `env` — Prints the current environment variables or defaults to the stdout, in a format that can be used as .env file. Environment variables have precedency over defaults
* `keys` — Create and manage identities including keys and addresses
* `network` — Start and configure networks
* `network` — Configure connection to networks
* `container` — Start local networks in containers
* `snapshot` — Download a snapshot of a ledger from an archive
* `tx` — Sign, Simulate, and Send transactions
* `xdr` — Decode and encode XDR
Expand Down Expand Up @@ -1105,7 +1106,7 @@ Set the default identity that will be used on all commands. This allows you to s

## `stellar network`

Start and configure networks
Configure connection to networks

**Usage:** `stellar network <COMMAND>`

Expand All @@ -1117,7 +1118,7 @@ Start and configure networks
* `start` — ⚠️ Deprecated: use `stellar container start` instead
* `stop` — ⚠️ Deprecated: use `stellar container stop` instead
* `use` — Set the default network that will be used on all commands. This allows you to skip `--network` or setting a environment variable, while reusing this value in all commands that require it
* `container`Commands to start, stop and get logs for a quickstart container
* `container`⚠️ Deprecated: use `stellar container` instead



Expand Down Expand Up @@ -1245,6 +1246,8 @@ Set the default network that will be used on all commands. This allows you to sk

## `stellar network container`

⚠️ Deprecated: use `stellar container` instead

Commands to start, stop and get logs for a quickstart container

**Usage:** `stellar network container <COMMAND>`
Expand All @@ -1253,7 +1256,7 @@ Commands to start, stop and get logs for a quickstart container

* `logs` — Get logs from a running network container
* `start` — Start a container running a Stellar node, RPC, API, and friendbot (faucet)
* `stop` — Stop a network container started with `network container start`
* `stop` — Stop a network container started with `stellar container start`



Expand All @@ -1277,7 +1280,7 @@ Get logs from a running network container

Start a container running a Stellar node, RPC, API, and friendbot (faucet).

`stellar network container start NETWORK [OPTIONS]`
`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:

Expand Down Expand Up @@ -1307,7 +1310,7 @@ By default, when starting a testnet container, without any optional arguments, i

## `stellar network container stop`

Stop a network container started with `network container start`
Stop a network container started with `stellar container start`

**Usage:** `stellar network container stop [OPTIONS] <NAME>`

Expand All @@ -1321,6 +1324,84 @@ Stop a network container started with `network container start`



## `stellar container`

Start local networks in containers

**Usage:** `stellar container <COMMAND>`

###### **Subcommands:**

* `logs` — Get logs from a running network container
* `start` — Start a container running a Stellar node, RPC, API, and friendbot (faucet)
* `stop` — Stop a network container started with `stellar container start`



## `stellar container logs`

Get logs from a running network container

**Usage:** `stellar container logs [OPTIONS] <NAME>`

###### **Arguments:**

* `<NAME>` — Container to get logs from

###### **Options:**

* `-d`, `--docker-host <DOCKER_HOST>` — Optional argument to override the default docker host. This is useful when you are using a non-standard docker host path for your Docker-compatible container runtime, e.g. Docker Desktop defaults to $HOME/.docker/run/docker.sock instead of /var/run/docker.sock



## `stellar container start`

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`

**Usage:** `stellar container start [OPTIONS] <NETWORK>`

###### **Arguments:**

* `<NETWORK>` — Network to start

Possible values: `local`, `testnet`, `futurenet`, `pubnet`


###### **Options:**

* `-d`, `--docker-host <DOCKER_HOST>` — Optional argument to override the default docker host. This is useful when you are using a non-standard docker host path for your Docker-compatible container runtime, e.g. Docker Desktop defaults to $HOME/.docker/run/docker.sock instead of /var/run/docker.sock
* `--name <NAME>` — Optional argument to specify the container name
* `-l`, `--limits <LIMITS>` — Optional argument to specify the limits for the local network only
* `-p`, `--ports-mapping <PORTS_MAPPING>` — Argument to specify the `HOST_PORT:CONTAINER_PORT` mapping

Default value: `8000:8000`
* `-t`, `--image-tag-override <IMAGE_TAG_OVERRIDE>` — Optional argument to override the default docker image tag for the given network
* `--protocol-version <PROTOCOL_VERSION>` — Optional argument to specify the protocol version for the local network only



## `stellar container stop`

Stop a network container started with `stellar container start`

**Usage:** `stellar container stop [OPTIONS] <NAME>`

###### **Arguments:**

* `<NAME>` — Container to stop

###### **Options:**

* `-d`, `--docker-host <DOCKER_HOST>` — Optional argument to override the default docker host. This is useful when you are using a non-standard docker host path for your Docker-compatible container runtime, e.g. Docker Desktop defaults to $HOME/.docker/run/docker.sock instead of /var/run/docker.sock



## `stellar snapshot`

Download a snapshot of a ledger from an archive
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use futures_util::TryStreamExt;

use crate::{
commands::{global, network::container::shared::Error as ConnectionError},
commands::{container::shared::Error as ConnectionError, global},
print,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ pub enum Cmd {
Logs(logs::Cmd),
/// Start a container running a Stellar node, RPC, API, and friendbot (faucet).
///
/// `stellar network container start NETWORK [OPTIONS]`
/// `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 `network container start`.
/// Stop a network container started with `stellar container start`.
Stop(stop::Cmd),
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use futures_util::TryStreamExt;

use crate::{
commands::{
container::shared::{Error as ConnectionError, Network},
global,
network::container::shared::{Error as ConnectionError, Network},
},
print,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{
commands::{global, network::container::shared::Error as BollardConnectionError},
commands::{container::shared::Error as BollardConnectionError, global},
print,
};

Expand Down
11 changes: 10 additions & 1 deletion cmd/soroban-cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::config;

pub mod cache;
pub mod completion;
pub mod container;
pub mod contract;
pub mod env;
pub mod events;
Expand Down Expand Up @@ -113,6 +114,7 @@ impl Root {
Cmd::Events(events) => events.run().await?,
Cmd::Xdr(xdr) => xdr.run()?,
Cmd::Network(network) => network.run(&self.global_args).await?,
Cmd::Container(container) => container.run(&self.global_args).await?,
Cmd::Snapshot(snapshot) => snapshot.run(&self.global_args).await?,
Cmd::Version(version) => version.run(),
Cmd::Keys(id) => id.run(&self.global_args).await?,
Expand Down Expand Up @@ -150,10 +152,14 @@ pub enum Cmd {
#[command(subcommand)]
Keys(keys::Cmd),

/// Start and configure networks
/// Configure connection to networks
#[command(subcommand)]
Network(network::Cmd),

/// Start local networks in containers
#[command(subcommand)]
Container(container::Cmd),

/// Download a snapshot of a ledger from an archive.
#[command(subcommand)]
Snapshot(snapshot::Cmd),
Expand Down Expand Up @@ -201,6 +207,9 @@ pub enum Error {
#[error(transparent)]
Network(#[from] network::Error),

#[error(transparent)]
Container(#[from] container::Error),

#[error(transparent)]
Snapshot(#[from] snapshot::Error),

Expand Down
21 changes: 12 additions & 9 deletions cmd/soroban-cli/src/commands/network/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use crate::rpc::{self};
use super::{config::locator, global};

pub mod add;
pub mod container;
pub mod default;
pub mod ls;
pub mod rm;
Expand All @@ -32,22 +31,24 @@ pub enum Cmd {
/// 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(container::StartCmd),
Start(crate::commands::container::StartCmd),

/// ⚠️ Deprecated: use `stellar container stop` instead
///
/// Stop a network started with `network start`. For example, if you ran `stellar network start local`, you can use `stellar network stop local` to stop it.
Stop(container::StopCmd),
Stop(crate::commands::container::StopCmd),

/// Set the default network that will be used on all commands.
/// This allows you to skip `--network` or setting a environment variable,
/// while reusing this value in all commands that require it.
#[command(name = "use")]
Default(default::Cmd),

/// ⚠️ Deprecated: use `stellar container` instead
///
/// Commands to start, stop and get logs for a quickstart container
#[command(subcommand)]
Container(container::Cmd),
Container(crate::commands::container::Cmd),
}

#[derive(thiserror::Error, Debug)]
Expand All @@ -66,14 +67,14 @@ pub enum Error {

// TODO: remove once `network start` is removed
#[error(transparent)]
Start(#[from] container::start::Error),
Start(#[from] crate::commands::container::start::Error),

// TODO: remove once `network stop` is removed
#[error(transparent)]
Stop(#[from] container::stop::Error),
Stop(#[from] crate::commands::container::stop::Error),

#[error(transparent)]
Container(#[from] container::Error),
Container(#[from] crate::commands::container::Error),

#[error(transparent)]
Config(#[from] locator::Error),
Expand Down Expand Up @@ -103,12 +104,14 @@ impl Cmd {

// TODO Remove this once `network start` is removed
Cmd::Start(cmd) => {
eprintln!("⚠️ Warning: `network start` has been deprecated. Use `network container start` instead");
eprintln!("⚠️ Warning: `network start` has been deprecated. Use `container start` instead");
cmd.run(global_args).await?;
}
// TODO Remove this once `network stop` is removed
Cmd::Stop(cmd) => {
println!("⚠️ Warning: `network stop` has been deprecated. Use `network container stop` instead");
println!(
"⚠️ Warning: `network stop` has been deprecated. Use `container stop` instead"
);
cmd.run(global_args).await?;
}
};
Expand Down

0 comments on commit 8e1d45b

Please sign in to comment.