Skip to main content

stellar_xdr/cli/xfile/
mod.rs

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