Enable colors on Windows, closes #427

This commit is contained in:
David Peter 2021-10-17 17:56:30 +02:00 committed by David Peter
parent 5c6b302591
commit 58d3eada61

View File

@ -145,6 +145,10 @@ fn main() {
fn build_hyperfine_options<'a>(
matches: &ArgMatches<'a>,
) -> Result<HyperfineOptions, OptionsError<'a>> {
// Enabled ANSI colors on Windows 10
#[cfg(windows)]
colored::control::set_virtual_terminal(true).unwrap();
let mut options = HyperfineOptions::default();
let param_to_u64 = |param| {
matches
@ -216,11 +220,6 @@ fn build_hyperfine_options<'a>(
}
};
// We default Windows to NoColor if full had been specified.
if cfg!(windows) && options.output_style == OutputStyleOption::Full {
options.output_style = OutputStyleOption::NoColor;
}
match options.output_style {
OutputStyleOption::Basic | OutputStyleOption::NoColor => {
colored::control::set_override(false)