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 4e616ef
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ hyper = "0.7.0"
rand = "0.3.11"
scopeguard = "0.1.2"
error-chain = { path = "../error-chain", version = "0.1.9" }
libc = "0.2.0"

[target.x86_64-pc-windows-gnu.dependencies]
winapi = "0.2.4"
Expand Down
4 changes: 4 additions & 0 deletions src/rustup-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@ extern crate advapi32;
#[cfg(windows)]
extern crate userenv;

#[cfg(unix)]
extern crate libc;

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 4e616ef

Please sign in to comment.