soroban_cli/commands/cfg/
mod.rs

1mod dir;
2mod migrate;
3
4use clap::Parser;
5
6/// Migrate config from previous versions.
7#[derive(Debug, Parser)]
8pub enum Cmd {
9    /// Migrate the local configuration to the global directory.
10    Migrate(migrate::Cmd),
11
12    /// Show the global configuration directory.
13    ///
14    /// The location will depend on how your system is configured.
15    ///
16    /// - It looks up for `XDG_CONFIG_HOME` environment variable. If it's set,
17    ///   `$XDG_CONFIG_HOME/stellar` will be used.
18    /// - If not set, it defaults to `$HOME/.config`.
19    /// - Can be overridden by `--config-dir` flag.
20    Dir(dir::Cmd),
21}
22
23#[derive(thiserror::Error, Debug)]
24pub enum Error {
25    #[error(transparent)]
26    Migrate(#[from] migrate::Error),
27
28    #[error(transparent)]
29    Dir(#[from] dir::Error),
30}
31
32impl Cmd {
33    pub fn run(&self) -> Result<(), Error> {
34        match self {
35            Cmd::Migrate(cmd) => cmd.run()?,
36            Cmd::Dir(cmd) => cmd.run()?,
37        }
38        Ok(())
39    }
40}