mirror of
https://github.com/lov3b/ecb-rates.git
synced 2025-02-22 18:00:11 +01:00
invert option
This commit is contained in:
parent
4445685444
commit
d842fb786c
@ -37,6 +37,10 @@ pub struct Cli {
|
|||||||
#[arg(long = "perspective", short = 'p')]
|
#[arg(long = "perspective", short = 'p')]
|
||||||
pub perspective: Option<String>,
|
pub perspective: Option<String>,
|
||||||
|
|
||||||
|
/// Invert the rate
|
||||||
|
#[arg(long = "invert", short = 'i')]
|
||||||
|
pub should_invert: bool,
|
||||||
|
|
||||||
/// Amount of data
|
/// Amount of data
|
||||||
#[arg(value_enum, default_value_t = Resolution::TODAY, long="resolution", short='r')]
|
#[arg(value_enum, default_value_t = Resolution::TODAY, long="resolution", short='r')]
|
||||||
pub resolution: Resolution,
|
pub resolution: Resolution,
|
||||||
|
@ -7,7 +7,7 @@ use ecb_rates::cli::{Cli, FormatOption};
|
|||||||
use ecb_rates::models::ExchangeRateResult;
|
use ecb_rates::models::ExchangeRateResult;
|
||||||
use ecb_rates::parsing::parse;
|
use ecb_rates::parsing::parse;
|
||||||
use ecb_rates::table::{TableRef, TableTrait as _};
|
use ecb_rates::table::{TableRef, TableTrait as _};
|
||||||
use ecb_rates::utils_calc::{change_perspective, filter_currencies};
|
use ecb_rates::utils_calc::{change_perspective, filter_currencies, invert_rates};
|
||||||
|
|
||||||
async fn get_and_parse(url: impl IntoUrl) -> anyhow::Result<Vec<ExchangeRateResult>> {
|
async fn get_and_parse(url: impl IntoUrl) -> anyhow::Result<Vec<ExchangeRateResult>> {
|
||||||
let client = Client::new();
|
let client = Client::new();
|
||||||
@ -80,6 +80,10 @@ async fn main() -> ExitCode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if cli.should_invert {
|
||||||
|
invert_rates(&mut parsed);
|
||||||
|
}
|
||||||
|
|
||||||
if !cli.currencies.is_empty() {
|
if !cli.currencies.is_empty() {
|
||||||
let currencies = cli
|
let currencies = cli
|
||||||
.currencies
|
.currencies
|
||||||
|
Loading…
x
Reference in New Issue
Block a user