diff --git a/src/cli.rs b/src/cli.rs index 5cd8fa1..89efc1a 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -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, diff --git a/src/main.rs b/src/main.rs index dbf4ef8..100c2d9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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());