Skip to content

Commit

Permalink
Use std::io::IsTerminal stabilized in Rust 1.70
Browse files Browse the repository at this point in the history
  • Loading branch information
HanabishiRecca committed Jun 1, 2023
1 parent b9cb2ed commit 894c361
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
1 change: 0 additions & 1 deletion 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
name = "aur-check-updates"
version = "1.0.3"
edition = "2021"
rust-version = "1.70"

[profile.release]
panic = "abort"

[dependencies]
alpm = "2.2"
curl = "0.4"
libc = "0.2"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
8 changes: 2 additions & 6 deletions src/print.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::{
fmt::Display,
io::{stdout, IsTerminal},
sync::atomic::{AtomicBool, Ordering::Relaxed},
};

Expand All @@ -12,16 +13,11 @@ pub enum ColorMode {
Never,
}

fn isatty() -> bool {
// SAFETY: This call should not have side effects.
unsafe { libc::isatty(libc::STDOUT_FILENO) == 1 }
}

pub fn set_color_mode(mode: ColorMode) {
use ColorMode::*;
COLOR.store(
match mode {
Auto => isatty(),
Auto => stdout().is_terminal(),
Always => true,
Never => false,
},
Expand Down

0 comments on commit 894c361

Please sign in to comment.