force color

This commit is contained in:
Love 2025-01-08 13:52:30 +01:00
parent dde5468e2b
commit ca846c390f
2 changed files with 8 additions and 0 deletions

View File

@ -25,6 +25,10 @@ pub struct Cli {
#[arg(long = "no-cache")]
pub no_cache: bool,
/// Force color in output. Normally it will disable color in pipes
#[arg(long = "force-color")]
pub force_color: bool,
/// Amount of data
#[arg(value_enum, default_value_t = Resolution::TODAY, long="resolution", short='r')]
pub resolution: Resolution,

View File

@ -35,6 +35,10 @@ fn filter_currencies(exchange_rate_results: &mut [ExchangeRateResult], currencie
#[tokio::main(flavor = "current_thread")]
async fn main() -> ExitCode {
let cli = Cli::parse();
if cli.force_color {
colored::control::set_override(true);
}
let use_cache = !cli.no_cache;
let cache = if use_cache { Cache::load() } else { None };
let cache_ok = cache.as_ref().map_or_else(|| false, |c| c.validate());