1+ //! Bothan CLI query subcommand module.
2+ //!
3+ //! Query prices and asset info from supported exchanges and data sources.
4+ //!
5+ //! Supports querying prices from multiple exchanges and data sources with customizable timeout and pretty-printed output.
6+ //!
7+ //! ## Features
8+ //!
9+ //! - Query prices from Binance, Bitfinex, Bybit, Coinbase, CoinGecko, CoinMarketCap, HTX, Kraken, OKX
10+ //! - Customizable timeout and query IDs
11+ //! - Pretty-printed table output
12+ //!
13+ //! ## Usage
14+ //!
15+ //! ```bash
16+ //! bothan query binance BTCUSDT ETHUSDT
17+ //! bothan query coingecko bitcoin ethereum
18+ //! ```
19+
120use std:: collections:: { HashMap , HashSet } ;
221use std:: error:: Error ;
322use std:: sync:: Arc ;
@@ -20,12 +39,14 @@ use tokio::time::timeout;
2039const DEFAULT_TIMEOUT : & str = "10s" ;
2140
2241#[ derive( Parser ) ]
42+ /// CLI arguments for the `query` command.
2343pub struct QueryCli {
2444 #[ command( subcommand) ]
2545 subcommand : QuerySubCommand ,
2646}
2747
2848#[ derive( Args , Debug , Clone ) ]
49+ /// Arguments for querying prices.
2950pub struct QueryArgs {
3051 /// The list of query ids to query prices for
3152 pub query_ids : Vec < String > ,
@@ -34,50 +55,59 @@ pub struct QueryArgs {
3455 #[ arg( short, long, default_value = DEFAULT_TIMEOUT ) ]
3556 pub timeout : HumanDuration ,
3657}
37-
3858#[ derive( Subcommand , Debug ) ]
59+ /// Supported query subcommands for each exchange or data source.
3960pub enum QuerySubCommand {
4061 /// Query Binance prices
62+ #[ clap( name = "binance" ) ]
4163 Binance {
4264 #[ clap( flatten) ]
4365 args : QueryArgs ,
4466 } ,
4567 /// Query Bitfinex prices
68+ #[ clap( name = "bitfinex" ) ]
4669 Bitfinex {
4770 #[ clap( flatten) ]
4871 args : QueryArgs ,
4972 } ,
5073 /// Query Bybit prices
74+ #[ clap( name = "bybit" ) ]
5175 Bybit {
5276 #[ clap( flatten) ]
5377 args : QueryArgs ,
5478 } ,
5579 /// Query Coinbase prices
80+ #[ clap( name = "coinbase" ) ]
5681 Coinbase {
5782 #[ clap( flatten) ]
5883 args : QueryArgs ,
5984 } ,
6085 /// Query CoinGecko prices
86+ #[ clap( name = "coingecko" ) ]
6187 CoinGecko {
6288 #[ clap( flatten) ]
6389 args : QueryArgs ,
6490 } ,
6591 /// Query CoinMarketCap prices
92+ #[ clap( name = "coinmarketcap" ) ]
6693 CoinMarketCap {
6794 #[ clap( flatten) ]
6895 args : QueryArgs ,
6996 } ,
7097 /// Query HTX prices
98+ #[ clap( name = "htx" ) ]
7199 Htx {
72100 #[ clap( flatten) ]
73101 args : QueryArgs ,
74102 } ,
75103 /// Query Kraken prices
104+ #[ clap( name = "kraken" ) ]
76105 Kraken {
77106 #[ clap( flatten) ]
78107 args : QueryArgs ,
79108 } ,
80109 /// Query OKX prices
110+ #[ clap( name = "okx" ) ]
81111 Okx {
82112 #[ clap( flatten) ]
83113 args : QueryArgs ,
0 commit comments