ecb_rates/cli/
cli_t.rs

1use clap::{Parser, ValueEnum};
2use smol_str::SmolStr;
3
4use super::{ShowDays, SortBy};
5
6#[derive(Debug, Parser)]
7#[command(author, version, about)]
8pub struct Cli {
9    /// Which currencies do you want to fetch rates for?
10    #[arg(long = "currencies", short = 'c')]
11    pub currencies: Vec<SmolStr>,
12
13    #[arg(value_enum, default_value_t = FormatOption::Plain)]
14    pub command: FormatOption,
15
16    /// Don't show time in output
17    #[arg(long = "no-time")]
18    pub no_time: bool,
19
20    /// Print currencies in a compact single line
21    #[arg(long = "compact")]
22    pub compact: bool,
23
24    /// Override the cache
25    #[arg(long = "no-cache")]
26    pub no_cache: bool,
27
28    /// Force color in output. Normally it will disable color in pipes
29    #[arg(long = "force-color")]
30    pub force_color: bool,
31
32    /// Sort by the currency name (in alphabetical order), or by the rate value (low -> high)
33    #[arg(value_enum, long = "sort-by", default_value_t = SortBy::Currency)]
34    pub sort_by: SortBy,
35
36    /// Recalculate to the perspective from an included currency
37    #[arg(long = "perspective", short = 'p')]
38    pub perspective: Option<SmolStr>,
39
40    /// Invert the rate
41    #[arg(long = "invert", short = 'i')]
42    pub should_invert: bool,
43
44    /// Max decimals to keep in price.
45    #[arg(long = "max-decimals", short = 'd', default_value_t = 5)]
46    pub max_decimals: u8,
47
48    /// Amount of data
49    #[arg(default_value_t = ShowDays::Days(1), long="show-days", short='s')]
50    pub show_days: ShowDays,
51}
52
53#[derive(Debug, Clone, Copy, ValueEnum)]
54pub enum FormatOption {
55    /// JSON output
56    Json,
57    /// Plain line-by-line output (with extra flags)
58    Plain,
59}