Skip to main content

soroban_cli/commands/network/
add.rs

1use crate::config::{address::NetworkName, locator, network, secret};
2
3#[derive(thiserror::Error, Debug)]
4pub enum Error {
5    #[error(transparent)]
6    Secret(#[from] secret::Error),
7
8    #[error(transparent)]
9    Config(#[from] locator::Error),
10
11    #[error(transparent)]
12    Network(#[from] network::Error),
13}
14
15#[derive(Debug, clap::Parser, Clone)]
16#[group(skip)]
17pub struct Cmd {
18    /// Name of network
19    pub name: NetworkName,
20
21    #[command(flatten)]
22    pub network: network::Network,
23
24    #[command(flatten)]
25    pub config_locator: locator::Args,
26}
27
28impl Cmd {
29    pub fn run(&self) -> Result<(), Error> {
30        self.network.validate_headers()?;
31        self.config_locator
32            .write_network(&self.name, &self.network)?;
33        Ok(())
34    }
35}