Skip to content

Commit 6e4dbe9

Browse files
authored
Merge pull request #79 from chrissimpkins/ansi-color
Add ANSI color support and improved standard stream formatting
2 parents 02bcfe9 + 2be5d90 commit 6e4dbe9

File tree

4 files changed

+37
-11
lines changed

4 files changed

+37
-11
lines changed

Cargo.lock

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ tee = "0.1"
3131
tempdir = "0.3.7"
3232
xz2 = "0.1.6"
3333
chrono = "0.4.11"
34+
colored="1.9"
3435

3536
[dev-dependencies]
3637
quickcheck = "0.9.2"

src/main.rs

+21-10
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use std::process::{self, Command};
1515
use std::str::FromStr;
1616

1717
use chrono::{Date, DateTime, Duration, Utc};
18+
use colored::*;
1819
use failure::{bail, format_err, Fail, Error};
1920
use log::debug;
2021
use reqwest::blocking::Client;
@@ -634,7 +635,13 @@ fn print_results(cfg: &Config, client: &Client, bisection_result: &BisectionResu
634635
}
635636
}
636637

637-
eprintln!("regression in {}", toolchains[*found]);
638+
let tc_found = format!("Regression in {}", toolchains[*found]);
639+
eprintln!("");
640+
eprintln!("");
641+
eprintln!("{}", "*".repeat(80).dimmed().bold());
642+
eprintln!("{}", tc_found.red());
643+
eprintln!("{}", "*".repeat(80).dimmed().bold());
644+
eprintln!("");
638645
}
639646

640647
fn print_final_report(
@@ -653,14 +660,16 @@ fn print_final_report(
653660
..
654661
} = ci_bisection_result;
655662

656-
eprintln!("");
657-
eprintln!("");
658-
659-
eprintln!("==================================================================================");
660-
eprintln!("= Please open an issue on Rust's github repository =");
661-
eprintln!("= https://github.com/rust-lang/rust/issues/new =");
662-
eprintln!("= Below you will find a text that would serve as a starting point of your report =");
663-
eprintln!("==================================================================================");
663+
#[rustfmt::skip]
664+
eprintln!("{}", "==================================================================================".dimmed());
665+
#[rustfmt::skip]
666+
eprintln!("{}", "= Please open an issue on Rust's github repository =".dimmed());
667+
#[rustfmt::skip]
668+
eprintln!("{}", "= https://github.com/rust-lang/rust/issues/new =".dimmed());
669+
#[rustfmt::skip]
670+
eprintln!("{}", "= Below you will find a text that would serve as a starting point of your report =".dimmed());
671+
#[rustfmt::skip]
672+
eprintln!("{}", "==================================================================================".dimmed());
664673

665674
eprintln!("");
666675

@@ -1071,6 +1080,7 @@ fn bisect_ci_in_commits(
10711080
}
10721081

10731082
eprintln!("validated commits found, specifying toolchains");
1083+
eprintln!("");
10741084

10751085
let toolchains = commits
10761086
.into_iter()
@@ -1142,7 +1152,8 @@ fn main() {
11421152
match err.downcast::<ExitError>() {
11431153
Ok(ExitError(code)) => process::exit(code),
11441154
Err(err) => {
1145-
eprintln!("ERROR: {}", err);
1155+
let error_str = "ERROR:".red().bold();
1156+
eprintln!("{} {}", error_str, err);
11461157
process::exit(1);
11471158
}
11481159
}

src/toolchains.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use std::path::{Path, PathBuf};
1212
use std::process::{self, Command, Stdio};
1313

1414
use chrono::{Date, naive, Utc};
15+
use colored::*;
1516
use dialoguer::Select;
1617
use failure::{Fail, Error};
1718
use flate2::read::GzDecoder;
@@ -139,7 +140,8 @@ impl Toolchain {
139140
client: &Client,
140141
dl_params: &DownloadParams,
141142
) -> Result<(), InstallError> {
142-
eprintln!("installing {}", self);
143+
let tc_stdstream_str = format!("{}", self);
144+
eprintln!("installing {}", tc_stdstream_str.green());
143145
let tmpdir = TempDir::new_in(&dl_params.tmp_dir, &self.rustup_name())
144146
.map_err(InstallError::TempDir)?;
145147
let dest = dl_params.install_dir.join(self.rustup_name());

0 commit comments

Comments
 (0)