Skip to main content

stellar_xdr/cli/xfile/
mod.rs

1pub mod preprocess;
2
3use clap::{Args, Subcommand};
4
5#[derive(thiserror::Error, Debug)]
6pub enum Error {
7    #[error("{0}")]
8    Preprocess(#[from] preprocess::Error),
9}
10
11#[derive(Args, Debug, Clone)]
12#[command()]
13pub struct Cmd {
14    #[command(subcommand)]
15    pub sub: Sub,
16}
17
18#[derive(Subcommand, Clone, Debug)]
19pub enum Sub {
20    /// Preprocess XDR .x files by evaluating #ifdef/#ifndef/#elif/#else/#endif directives
21    Preprocess(preprocess::Cmd),
22}
23
24impl Cmd {
25    /// Run the CLIs xfile command.
26    ///
27    /// ## Errors
28    ///
29    /// If the sub-command is configured with state that is invalid.
30    pub fn run(&self) -> Result<(), Error> {
31        match &self.sub {
32            Sub::Preprocess(c) => c.run()?,
33        }
34        Ok(())
35    }
36}