soroban_cli/commands/network/
default.rs

1use crate::{commands::global, print::Print};
2
3use super::locator;
4
5#[derive(thiserror::Error, Debug)]
6pub enum Error {
7    #[error(transparent)]
8    Config(#[from] locator::Error),
9}
10
11#[derive(Debug, clap::Parser, Clone)]
12#[group(skip)]
13pub struct Cmd {
14    /// Set the default network name.
15    pub name: String,
16
17    #[command(flatten)]
18    pub config_locator: locator::Args,
19}
20
21impl Cmd {
22    pub fn run(&self, global_args: &global::Args) -> Result<(), Error> {
23        let printer = Print::new(global_args.quiet);
24        let _ = self.config_locator.read_network(&self.name)?;
25
26        self.config_locator.write_default_network(&self.name)?;
27
28        printer.infoln(format!("The default network is set to `{}`", self.name));
29
30        Ok(())
31    }
32}