From 34be81c21688359618f47bb30bee8921b2041417 Mon Sep 17 00:00:00 2001 From: "andy.boot" Date: Tue, 2 Jun 2020 13:45:12 +0100 Subject: [PATCH] Windows: If no color flag is already set ... then do not print a warning message https://github.com/bootandy/dust/issues/87 --- src/main.rs | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/main.rs b/src/main.rs index beb3fe5..ee68804 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,15 +20,20 @@ static DEFAULT_NUMBER_OF_LINES: usize = 30; #[cfg(windows)] fn init_color(no_color: bool) -> bool { - // Required for windows 10 - // Fails to resolve for windows 8 so disable color - match ansi_term::enable_ansi_support() { - Ok(_) => no_color, - Err(_) => { - eprintln!( - "This version of Windows does not support ANSI colors, setting no_color flag" - ); - true + // If no color is already set do not print a warning message + if no_color { + true + } else { + // Required for windows 10 + // Fails to resolve for windows 8 so disable color + match ansi_term::enable_ansi_support() { + Ok(_) => no_color, + Err(_) => { + eprintln!( + "This version of Windows does not support ANSI colors, setting no_color flag" + ); + true + } } } }