Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable colors on Windows #441

Merged
merged 1 commit into from
Oct 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down