Redo color disable on windows

This commit is contained in:
Malte Tammena 2021-10-24 18:08:25 +02:00
parent fd83b36907
commit 770056e847

View file

@ -74,8 +74,13 @@ use tracing::error;
///
/// This will colorize for Stdout based on heuristics and colors
/// from the [`owo_colors`] library.
///
/// **Windows**: Automatic color defaults to no color at the moment!
// TODO: Make colors work on windows
macro_rules! color {
($what:expr; $($fn:ident),+) => {
{
#[cfg(not(windows))]
{
use owo_colors::{OwoColorize, Stream};
use crate::config::args::ColorWhen;
@ -84,18 +89,28 @@ macro_rules! color {
$what $(. $fn())+ .to_string()
}
ColorWhen::Automatic => {
// TODO: Colors don't seem to work on windows
#[cfg(not(windows))]
{ $what.if_supports_color(Stream::Stdout,
|txt| txt $(. $fn().to_string())+).to_string() }
#[cfg(windows)]
$what.to_string()
$what.if_supports_color(Stream::Stdout,
|txt| txt $(. $fn().to_string())+).to_string()
}
ColorWhen::Never => {
$what.to_string()
}
}
}
#[cfg(windows)]
{
use owo_colors::{OwoColorize};
use crate::config::args::ColorWhen;
match crate::config::CONF.args.color {
ColorWhen::Always => {
$what $(. $fn())+ .to_string()
}
ColorWhen::Automatic | ColorWhen::Never => {
$what.to_string()
}
}
}
}
};
}