Skip to main content

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
10#[derive(thiserror::Error, Debug)]
11pub enum Error {
12    #[error("{0}")]
13    SchemaError(#[from] schema::Error),
14    #[error("{0}")]
15    SchemaFilesError(#[from] schema_files::Error),
16}
17
18#[derive(Args, Debug, Clone)]
19#[command()]
20pub struct Cmd {
21    #[command(subcommand)]
22    pub sub: Sub,
23}
24
25#[derive(Subcommand, Clone, Debug)]
26pub enum Sub {
27    List(list::Cmd),
28    Schema(schema::Cmd),
29    SchemaFiles(schema_files::Cmd),
30}
31
32impl Cmd {
33    /// Run the CLIs types command.
34    ///
35    /// ## Errors
36    ///
37    /// If the sub-command panics.
38    ///
39    /// ## Panics
40    ///
41    /// If the sub-command panics.
42    pub fn run(&self) -> Result<(), Error> {
43        match &self.sub {
44            Sub::List(c) => c.run(),
45            Sub::Schema(c) => c.run()?,
46            Sub::SchemaFiles(c) => c.run()?,
47        }
48        Ok(())
49    }
50}