hermes_cli/commands/query/
mod.rs

1mod connection;
2pub use connection::QueryConnection;
3
4mod clients;
5pub use clients::QueryClients;
6
7mod connections;
8pub use connections::QueryConnections;
9
10mod channel;
11pub use channel::QueryChannel;
12
13mod channels;
14pub use channels::QueryChannels;
15
16mod packet;
17use hermes_cli_components::impls::commands::queries::client::QueryClientSubCommand;
18use hermes_cli_components::traits::command::CanRunCommand;
19use hermes_cli_framework::command::CommandRunner;
20use hermes_cli_framework::output::Output;
21pub use packet::PacketCommands;
22
23use crate::contexts::app::HermesApp;
24use crate::Result;
25
26/// All subcommands for querying IBC-related objects and data.
27#[derive(Debug, clap::Subcommand)]
28pub enum QueryCommands {
29    /// Query all clients
30    Clients(QueryClients),
31
32    /// Query all connections
33    Connections(QueryConnections),
34
35    /// Query all channels
36    Channels(QueryChannels),
37
38    /// Query information about IBC clients
39    #[clap(subcommand)]
40    Client(QueryClientSubCommand),
41
42    /// Query connection information
43    #[clap(subcommand)]
44    Connection(QueryConnection),
45
46    /// Query channel information
47    #[clap(subcommand)]
48    Channel(QueryChannel),
49
50    /// Query information about IBC packets
51    #[clap(subcommand)]
52    Packet(PacketCommands),
53}
54
55impl CommandRunner<HermesApp> for QueryCommands {
56    async fn run(&self, app: &HermesApp) -> Result<Output> {
57        match self {
58            Self::Client(cmd) => app.run_command(cmd).await,
59            Self::Clients(cmd) => cmd.run(app).await,
60            Self::Connection(cmd) => cmd.run(app).await,
61            Self::Connections(cmd) => cmd.run(app).await,
62            Self::Channels(cmd) => cmd.run(app).await,
63            Self::Channel(cmd) => cmd.run(app).await,
64            Self::Packet(cmd) => cmd.run(app).await,
65        }
66    }
67}