soroban_cli/commands/ledger/
mod.rs

1use crate::commands::global;
2use clap::Subcommand;
3pub mod entry;
4mod fetch;
5mod latest;
6
7#[derive(Debug, Subcommand)]
8pub enum Cmd {
9    /// Work with ledger entries.
10    #[command(subcommand)]
11    Entry(entry::Cmd),
12    /// Get the latest ledger sequence and information from the network
13    Latest(latest::Cmd),
14    Fetch(fetch::Cmd),
15}
16
17#[derive(thiserror::Error, Debug)]
18pub enum Error {
19    #[error(transparent)]
20    Entry(#[from] entry::Error),
21    #[error(transparent)]
22    Latest(#[from] latest::Error),
23    #[error(transparent)]
24    Fetch(#[from] fetch::Error),
25}
26
27impl Cmd {
28    pub async fn run(&self, global_args: &global::Args) -> Result<(), Error> {
29        match &self {
30            Cmd::Entry(cmd) => cmd.run().await?,
31            Cmd::Latest(cmd) => cmd.run(global_args).await?,
32            Cmd::Fetch(cmd) => cmd.run(global_args).await?,
33        }
34        Ok(())
35    }
36}