Skip to content

Commit

Permalink
Refactoring TTY checks into rustup-utils
Browse files Browse the repository at this point in the history
  • Loading branch information
peschkaj committed May 5, 2016
1 parent 740b51e commit c2663a0
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/rustup-cli/download_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use time::precise_time_s;
use rustup::Notification;
use rustup_dist::Notification as In;
use rustup_utils::Notification as Un;
use tty;
use rustup_utils::tty;

/// Keep track of this many past download amounts
const DOWNLOAD_TRACK_COUNT: usize = 5;
Expand Down
1 change: 0 additions & 1 deletion src/rustup-cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ mod proxy_mode;
mod setup_mode;
mod rustup_mode;
mod self_update;
mod tty;
mod job;
mod term2;
mod errors;
Expand Down
2 changes: 1 addition & 1 deletion src/rustup-cli/term2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use std::io;
use term;
use tty;
use rustup_utils::tty;

pub use term::color;
pub use term::Attr;
Expand Down
1 change: 1 addition & 0 deletions src/rustup-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub mod notify;
pub mod errors;
pub mod notifications;
pub mod raw;
pub mod tty;
pub mod utils;

pub use errors::*;
Expand Down
File renamed without changes.
10 changes: 6 additions & 4 deletions src/rustup/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ fn telemetry_rustc<S: AsRef<OsStr>>(mut cmd: Command, args: &[S], cfg: &Cfg) ->

cmd.args(&args[1..]);

if stderr_isatty() && !(&args).iter().any(|e| {
let e = e.as_ref().to_str().unwrap_or("");
e == "--color"
})
let has_color_args = (&args).iter().any(|e| {
let e = e.as_ref().to_str().unwrap_or("");
e.starts_with("--color")
});

if stderr_isatty() && !has_color_args
{
cmd.arg("--color");
cmd.arg("always");
Expand Down

0 comments on commit c2663a0

Please sign in to comment.