stellar_xdr/cli/
types.rs

1pub mod list;
2pub mod schema;
3pub mod schema_files;
4
5#[deprecated = "use crate::schemars"]
6pub use crate::schemars as schema_settings;
7
8use clap::{Args, Subcommand};
9
10use crate::cli::Channel;
11
12#[derive(thiserror::Error, Debug)]
13pub enum Error {
14    #[error("{0}")]
15    SchemaError(#[from] schema::Error),
16    #[error("{0}")]
17    SchemaFilesError(#[from] schema_files::Error),
18}
19
20#[derive(Args, Debug, Clone)]
21#[command()]
22pub struct Cmd {
23    #[command(subcommand)]
24    pub sub: Sub,
25}
26
27#[derive(Subcommand, Clone, Debug)]
28pub enum Sub {
29    List(list::Cmd),
30    Schema(schema::Cmd),
31    SchemaFiles(schema_files::Cmd),
32}
33
34impl Cmd {
35    /// Run the CLIs types command.
36    ///
37    /// ## Errors
38    ///
39    /// If the sub-command panics.
40    ///
41    /// ## Panics
42    ///
43    /// If the sub-command panics.
44    pub fn run(&self, channel: &Channel) -> Result<(), Error> {
45        match &self.sub {
46            Sub::List(c) => c.run(channel),
47            Sub::Schema(c) => c.run(channel)?,
48            Sub::SchemaFiles(c) => c.run(channel)?,
49        }
50        Ok(())
51    }
52}