Switch from deprecated isatty to atty

Josh Triplett created

Change summary

Cargo.lock  | 14 +-------------
Cargo.toml  |  2 +-
src/main.rs | 10 +++++-----
3 files changed, 7 insertions(+), 19 deletions(-)

Detailed changes

Cargo.lock 🔗

@@ -103,11 +103,11 @@ name = "git-series"
 version = "0.9.1"
 dependencies = [
  "ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)",
  "chrono 0.2.25 (registry+https://github.com/rust-lang/crates.io-index)",
  "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "colorparse 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "git2 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "isatty 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
  "munkres 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -137,17 +137,6 @@ dependencies = [
  "unicode-normalization 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
-[[package]]
-name = "isatty"
-version = "0.1.9"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)",
- "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
 [[package]]
 name = "jobserver"
 version = "0.1.17"
@@ -462,7 +451,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 "checksum getrandom 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "473a1265acc8ff1e808cd0a1af8cee3c2ee5200916058a2ca113c29f2d903571"
 "checksum git2 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "39f27186fbb5ec67ece9a56990292bc5aed3c3fc51b9b07b0b52446b1dfb4a82"
 "checksum idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9"
-"checksum isatty 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e31a8281fc93ec9693494da65fbf28c0c2aa60a2eaec25dc58e2f31952e95edc"
 "checksum jobserver 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b1d42ef453b30b7387e113da1c83ab1605d90c5b4e0eb8e96d016ed3b8c160"
 "checksum libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)" = "34fcd2c08d2f832f376f4173a231990fa5aef4e99fb569867318a227ef4c06ba"
 "checksum libgit2-sys 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a30f8637eb59616ee3b8a00f6adff781ee4ddd8343a615b8238de756060cc1b3"

Cargo.toml 🔗

@@ -9,11 +9,11 @@ description = "Track patch series in git"
 
 [dependencies]
 ansi_term = "0.9.0"
+atty = "0.2.13"
 chrono = "0.2.22"
 clap = "2.7.0"
 colorparse = "2.0"
 git2 = "0.10"
-isatty = "0.1.1"
 munkres = "0.3.0"
 quick-error = "1.0"
 tempdir = "0.3.4"

src/main.rs 🔗

@@ -1,10 +1,10 @@
 extern crate ansi_term;
+extern crate atty;
 extern crate chrono;
 #[macro_use]
 extern crate clap;
 extern crate colorparse;
 extern crate git2;
-extern crate isatty;
 extern crate munkres;
 #[macro_use]
 extern crate quick_error;
@@ -395,7 +395,7 @@ fn checkout_tree(repo: &Repository, treeish: &Object) -> Result<()> {
             }
             true
         });
-        if isatty::stdout_isatty() {
+        if atty::is(atty::Stream::Stdout) {
             opts.progress(|_, completed, total| {
                 let total = total.to_string();
                 print!("\rChecking out files: {1:0$}/{2}", total.len(), completed, total);
@@ -573,7 +573,7 @@ fn get_editor(config: &Config) -> Result<OsString> {
 // Get the pager to use; with for_cmd set, get the pager for use by the
 // specified git command.  If get_pager returns None, don't use a pager.
 fn get_pager(config: &Config, for_cmd: &str, default: bool) -> Option<OsString> {
-    if !isatty::stdout_isatty() {
+    if !atty::is(atty::Stream::Stdout) {
         return None;
     }
     // pager.cmd can contain a boolean (if false, force no pager) or a
@@ -654,7 +654,7 @@ impl Output {
             }
             let child = try!(cmd.spawn());
             self.pager = Some(child);
-            self.include_stderr = isatty::stderr_isatty();
+            self.include_stderr = atty::is(atty::Stream::Stderr);
         }
         Ok(())
     }
@@ -679,7 +679,7 @@ impl Output {
             if !color_pager {
                 return Ok(Style::new());
             }
-        } else if !isatty::stdout_isatty() {
+        } else if !atty::is(atty::Stream::Stdout) {
             return Ok(Style::new());
         }
         let cfg = format!("color.{}.{}", command, slot);