|
6 | 6 | //! |
7 | 7 | //! ## Features |
8 | 8 | //! |
9 | | -//! - Query prices from Binance, Bitfinex, Bybit, Coinbase, CoinGecko, CoinMarketCap, HTX, Kraken, OKX |
| 9 | +//! - Query prices from Binance, Bitfinex, Bybit, Coinbase, CoinGecko, CoinMarketCap, HTX, Kraken, OKX, Band (Kiwi, Macaw, Owlet, Fieldfare, Xenops) |
10 | 10 | //! - Customizable timeout and query IDs |
11 | 11 | //! - Pretty-printed table output |
12 | 12 | //! |
@@ -124,55 +124,90 @@ pub enum QuerySubCommand { |
124 | 124 | #[clap(flatten)] |
125 | 125 | args: QueryArgs, |
126 | 126 | }, |
| 127 | + /// Query Band/owlet prices |
| 128 | + #[clap(name = "band/owlet")] |
| 129 | + BandOwlet { |
| 130 | + #[clap(flatten)] |
| 131 | + args: QueryArgs, |
| 132 | + }, |
| 133 | + /// Query Band/fieldfare prices |
| 134 | + #[clap(name = "band/fieldfare")] |
| 135 | + BandFieldfare { |
| 136 | + #[clap(flatten)] |
| 137 | + args: QueryArgs, |
| 138 | + }, |
| 139 | + /// Query Band/xenops prices |
| 140 | + #[clap(name = "band/xenops")] |
| 141 | + BandXenops { |
| 142 | + #[clap(flatten)] |
| 143 | + args: QueryArgs, |
| 144 | + }, |
127 | 145 | } |
128 | 146 |
|
129 | 147 | impl QueryCli { |
130 | 148 | pub async fn run(&self, app_config: AppConfig) -> anyhow::Result<()> { |
131 | | - let source_config = app_config.manager.crypto.source; |
| 149 | + let crypto_config = app_config.manager.crypto.and_then(|c| c.source); |
| 150 | + let forex_config = app_config.manager.forex.and_then(|f| f.source); |
132 | 151 | let config_err = anyhow!("Config is missing. Please check your config.toml."); |
133 | 152 | match &self.subcommand { |
134 | 153 | QuerySubCommand::Binance { args } => { |
135 | | - let opts = source_config.binance.ok_or(config_err)?; |
| 154 | + let opts = crypto_config.and_then(|c| c.binance).ok_or(config_err)?; |
136 | 155 | query_binance(opts, &args.query_ids, args.timeout).await?; |
137 | 156 | } |
138 | 157 | QuerySubCommand::Bitfinex { args } => { |
139 | | - let opts = source_config.bitfinex.ok_or(config_err)?; |
| 158 | + let opts = crypto_config.and_then(|c| c.bitfinex).ok_or(config_err)?; |
140 | 159 | query_bitfinex(opts, &args.query_ids, args.timeout).await?; |
141 | 160 | } |
142 | 161 | QuerySubCommand::Bybit { args } => { |
143 | | - let opts = source_config.bybit.ok_or(config_err)?; |
| 162 | + let opts = crypto_config.and_then(|c| c.bybit).ok_or(config_err)?; |
144 | 163 | query_bybit(opts, &args.query_ids, args.timeout).await?; |
145 | 164 | } |
146 | 165 | QuerySubCommand::Coinbase { args } => { |
147 | | - let opts = source_config.coinbase.ok_or(config_err)?; |
| 166 | + let opts = crypto_config.and_then(|c| c.coinbase).ok_or(config_err)?; |
148 | 167 | query_coinbase(opts, &args.query_ids, args.timeout).await?; |
149 | 168 | } |
150 | 169 | QuerySubCommand::CoinGecko { args } => { |
151 | | - let opts = source_config.coingecko.ok_or(config_err)?; |
| 170 | + let opts = crypto_config.and_then(|c| c.coingecko).ok_or(config_err)?; |
152 | 171 | query_coingecko(opts, &args.query_ids, args.timeout).await?; |
153 | 172 | } |
154 | 173 | QuerySubCommand::CoinMarketCap { args } => { |
155 | | - let opts = source_config.coinmarketcap.ok_or(config_err)?; |
| 174 | + let opts = crypto_config |
| 175 | + .and_then(|c| c.coinmarketcap) |
| 176 | + .ok_or(config_err)?; |
156 | 177 | query_coinmarketcap(opts, &args.query_ids, args.timeout).await?; |
157 | 178 | } |
158 | 179 | QuerySubCommand::Htx { args } => { |
159 | | - let opts = source_config.htx.ok_or(config_err)?; |
| 180 | + let opts = crypto_config.and_then(|c| c.htx).ok_or(config_err)?; |
160 | 181 | query_htx(opts, &args.query_ids, args.timeout).await?; |
161 | 182 | } |
162 | 183 | QuerySubCommand::Kraken { args } => { |
163 | | - let opts = source_config.kraken.ok_or(config_err)?; |
| 184 | + let opts = crypto_config.and_then(|c| c.kraken).ok_or(config_err)?; |
164 | 185 | query_kraken(opts, &args.query_ids, args.timeout).await?; |
165 | 186 | } |
166 | 187 | QuerySubCommand::Okx { args } => { |
167 | | - let opts = source_config.okx.ok_or(config_err)?; |
| 188 | + let opts = crypto_config.and_then(|c| c.okx).ok_or(config_err)?; |
168 | 189 | query_okx(opts, &args.query_ids, args.timeout).await?; |
169 | 190 | } |
170 | 191 | QuerySubCommand::BandKiwi { args } => { |
171 | | - let opts = source_config.band_kiwi.ok_or(config_err)?; |
| 192 | + let opts = crypto_config.and_then(|c| c.band_kiwi).ok_or(config_err)?; |
172 | 193 | query_band(opts, &args.query_ids, args.timeout).await?; |
173 | 194 | } |
174 | 195 | QuerySubCommand::BandMacaw { args } => { |
175 | | - let opts = source_config.band_macaw.ok_or(config_err)?; |
| 196 | + let opts = crypto_config.and_then(|c| c.band_macaw).ok_or(config_err)?; |
| 197 | + query_band(opts, &args.query_ids, args.timeout).await?; |
| 198 | + } |
| 199 | + QuerySubCommand::BandOwlet { args } => { |
| 200 | + let opts = forex_config.and_then(|f| f.band_owlet).ok_or(config_err)?; |
| 201 | + query_band(opts, &args.query_ids, args.timeout).await?; |
| 202 | + } |
| 203 | + QuerySubCommand::BandFieldfare { args } => { |
| 204 | + let opts = forex_config |
| 205 | + .and_then(|f| f.band_fieldfare) |
| 206 | + .ok_or(config_err)?; |
| 207 | + query_band(opts, &args.query_ids, args.timeout).await?; |
| 208 | + } |
| 209 | + QuerySubCommand::BandXenops { args } => { |
| 210 | + let opts = forex_config.and_then(|f| f.band_xenops).ok_or(config_err)?; |
176 | 211 | query_band(opts, &args.query_ids, args.timeout).await?; |
177 | 212 | } |
178 | 213 | } |
|
0 commit comments