stellar_xdr/cli/
types.rs

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