soroban_cli/commands/network/
mod.rs1use super::{config::locator, global};
2use clap::Parser;
3
4pub mod add;
5pub mod default;
6pub mod health;
7pub mod info;
8pub mod ls;
9pub mod rm;
10pub mod settings;
11
12#[derive(Debug, Parser)]
13pub enum Cmd {
14 Add(add::Cmd),
16
17 Rm(rm::Cmd),
19
20 Ls(ls::Cmd),
22
23 #[cfg(feature = "version_lt_23")]
35 Start(crate::commands::container::StartCmd),
36
37 #[cfg(feature = "version_lt_23")]
41 Stop(crate::commands::container::StopCmd),
42
43 #[command(name = "use")]
47 Default(default::Cmd),
48
49 #[cfg(feature = "version_lt_23")]
53 #[command(subcommand)]
54 Container(crate::commands::container::Cmd),
55
56 Health(health::Cmd),
58
59 Info(info::Cmd),
61
62 Settings(settings::Cmd),
64}
65
66#[derive(thiserror::Error, Debug)]
67pub enum Error {
68 #[error(transparent)]
69 Default(#[from] default::Error),
70
71 #[error(transparent)]
72 Add(#[from] add::Error),
73
74 #[error(transparent)]
75 Rm(#[from] rm::Error),
76
77 #[error(transparent)]
78 Ls(#[from] ls::Error),
79
80 #[error(transparent)]
81 Health(#[from] health::Error),
82
83 #[error(transparent)]
84 Info(#[from] info::Error),
85
86 #[error(transparent)]
87 Settings(#[from] settings::Error),
88
89 #[cfg(feature = "version_lt_23")]
90 #[error(transparent)]
91 Start(#[from] crate::commands::container::start::Error),
92
93 #[cfg(feature = "version_lt_23")]
94 #[error(transparent)]
95 Stop(#[from] crate::commands::container::stop::Error),
96
97 #[cfg(feature = "version_lt_23")]
98 #[error(transparent)]
99 Container(#[from] crate::commands::container::Error),
100}
101
102impl Cmd {
103 pub async fn run(&self, global_args: &global::Args) -> Result<(), Error> {
104 match self {
105 Cmd::Default(cmd) => cmd.run(global_args)?,
106 Cmd::Add(cmd) => cmd.run()?,
107 Cmd::Rm(new) => new.run()?,
108 Cmd::Ls(cmd) => cmd.run()?,
109 #[cfg(feature = "version_lt_23")]
110 Cmd::Container(cmd) => cmd.run(global_args).await?,
111
112 #[cfg(feature = "version_lt_23")]
113 Cmd::Start(cmd) => {
114 eprintln!("⚠️ Warning: `network start` has been deprecated. Use `container start` instead");
115 cmd.run(global_args).await?;
116 }
117 #[cfg(feature = "version_lt_23")]
118 Cmd::Stop(cmd) => {
119 println!(
120 "⚠️ Warning: `network stop` has been deprecated. Use `container stop` instead"
121 );
122 cmd.run(global_args).await?;
123 }
124 Cmd::Health(cmd) => cmd.run(global_args).await?,
125 Cmd::Info(cmd) => cmd.run(global_args).await?,
126 Cmd::Settings(cmd) => cmd.run(global_args).await?,
127 }
128 Ok(())
129 }
130}