summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornickelc <constantin.nickel@gmail.com>2023-07-09 00:00:36 +0200
committerGitHub <noreply@github.com>2023-07-08 18:00:36 -0400
commit915662f5da4d8058c0bc6496a502c4b4ce28fe7d (patch)
tree904c4cccc03f4cf38c9282250b1fd94ac2db73cb
parentff5fd061f4dfc9b00f80aada705de192a5524ed5 (diff)
Replace usage of the `atty` crate with `std::io::IsTerminal` trait (#1465)
Rust 1.70 stabilized the `IsTerminal` trait and the newest version of `grep-cli` crate depending on it, makes it possible to remove the unmaintained `atty` crate from the build. ``` Crate: atty Version: 0.2.14 Warning: unsound Title: Potential unaligned read Date: 2021-07-04 ID: RUSTSEC-2021-0145 URL: https://rustsec.org/advisories/RUSTSEC-2021-0145 ```
-rw-r--r--Cargo.lock37
-rw-r--r--Cargo.toml3
-rw-r--r--src/delta.rs5
-rw-r--r--src/main.rs4
-rw-r--r--src/subcommands/list_syntax_themes.rs4
-rw-r--r--src/subcommands/show_syntax_themes.rs4
-rw-r--r--src/subcommands/show_themes.rs4
7 files changed, 18 insertions, 43 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 4fb2c364..70eea6b4 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -72,17 +72,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6"
[[package]]
-name = "atty"
-version = "0.2.14"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
-dependencies = [
- "hermit-abi 0.1.19",
- "libc",
- "winapi",
-]
-
-[[package]]
name = "autocfg"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -151,12 +140,11 @@ checksum = "ea27d8d5fd867b17523bf6788b1175fa9867f34669d057e9adaf76e27bcea44b"
[[package]]
name = "bstr"
-version = "1.3.0"
+version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5ffdb39cb703212f3c11973452c2861b972f757b021158f3516ba10f2fa8b2c1"
+checksum = "6798148dccfbff0fae41c7574d2fa8f1ef3492fba0face179de5d8d447d67b05"
dependencies = [
"memchr",
- "once_cell",
"regex-automata",
"serde",
]
@@ -562,7 +550,6 @@ dependencies = [
"ansi_colours",
"ansi_term",
"anyhow",
- "atty",
"bat",
"bitflags 2.2.1",
"box_drawing",
@@ -620,11 +607,10 @@ dependencies = [
[[package]]
name = "grep-cli"
-version = "0.1.7"
+version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d19fc6687bc64b6719a839cd24f2c700bcb05ffeb684d19da6a637c2455a7ba1"
+checksum = "a174e093eaf510f24dae4b4dd996787d6e299069f05af7437996e91b029a8f8d"
dependencies = [
- "atty",
"bstr",
"globset",
"lazy_static",
@@ -649,15 +635,6 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
[[package]]
name = "hermit-abi"
-version = "0.1.19"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
-dependencies = [
- "libc",
-]
-
-[[package]]
-name = "hermit-abi"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286"
@@ -722,7 +699,7 @@ version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21b6b32576413a8e69b90e952e4a026476040d81017b80445deda5f2d3921857"
dependencies = [
- "hermit-abi 0.3.1",
+ "hermit-abi",
"io-lifetimes",
"rustix",
"windows-sys 0.45.0",
@@ -1135,9 +1112,9 @@ dependencies = [
[[package]]
name = "regex-automata"
-version = "0.1.10"
+version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
+checksum = "83d3daa6976cffb758ec878f108ba0e062a45b2d6ca3a2cca965338855476caf"
[[package]]
name = "regex-syntax"
diff --git a/Cargo.toml b/Cargo.toml
index 2b36a6d0..d4403865 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -21,7 +21,6 @@ chrono-humanize = "0.2.2"
ansi_colours = "1.2.1"
ansi_term = "0.12.1"
anyhow = "1.0.70"
-atty = "0.2.14"
bitflags = "2.2.1"
box_drawing = "0.1.2"
bytelines = "=2.2.2" # Pin version until its tokio and futures dependencies are optional.
@@ -29,7 +28,7 @@ clap = { version = "4.1.11", features = ["derive", "help", "usage", "error-conte
console = "0.15.0"
ctrlc = "3.2.5"
dirs = "5.0.1"
-grep-cli = "0.1.7"
+grep-cli = "0.1.8"
itertools = "0.10.5"
lazy_static = "1.4"
palette = "0.7.2"
diff --git a/src/delta.rs b/src/delta.rs
index 7db15575..3bce32a1 100644
--- a/src/delta.rs
+++ b/src/delta.rs
@@ -1,7 +1,6 @@
use std::borrow::Cow;
use std::collections::HashMap;
-use std::io::BufRead;
-use std::io::Write;
+use std::io::{self, BufRead, IsTerminal, Write};
use bytelines::ByteLines;
@@ -260,7 +259,7 @@ impl<'a> StateMachine<'a> {
/// If output is going to a tty, emit hyperlinks if requested.
// Although raw output should basically be emitted unaltered, we do this.
pub fn format_raw_line<'a>(line: &'a str, config: &Config) -> Cow<'a, str> {
- if config.hyperlinks && atty::is(atty::Stream::Stdout) {
+ if config.hyperlinks && io::stdout().is_terminal() {
features::hyperlinks::format_commit_line_with_osc8_commit_hyperlink(line, config)
} else {
Cow::from(line)
diff --git a/src/main.rs b/src/main.rs
index caf94cac..a1f12622 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -24,7 +24,7 @@ mod subcommands;
mod tests;
-use std::io::{self, ErrorKind};
+use std::io::{self, ErrorKind, IsTerminal};
use std::process;
use bytelines::ByteLinesReader;
@@ -130,7 +130,7 @@ fn run_app() -> std::io::Result<i32> {
return Ok(exit_code);
}
- if atty::is(atty::Stream::Stdin) {
+ if io::stdin().is_terminal() {
eprintln!(
"\
The main way to use delta is to configure it as the pager for git: \
diff --git a/src/subcommands/list_syntax_themes.rs b/src/subcommands/list_syntax_themes.rs
index 621932e7..087e8858 100644
--- a/src/subcommands/list_syntax_themes.rs
+++ b/src/subcommands/list_syntax_themes.rs
@@ -1,4 +1,4 @@
-use std::io::{self, Write};
+use std::io::{self, IsTerminal, Write};
use itertools::Itertools;
@@ -8,7 +8,7 @@ use crate::{options::theme::is_light_syntax_theme, utils};
pub fn list_syntax_themes() -> std::io::Result<()> {
let stdout = io::stdout();
let mut stdout = stdout.lock();
- if atty::is(atty::Stream::Stdout) {
+ if stdout.is_terminal() {
_list_syntax_themes_for_humans(&mut stdout)
} else {
_list_syntax_themes_for_machines(&mut stdout)
diff --git a/src/subcommands/show_syntax_themes.rs b/src/subcommands/show_syntax_themes.rs
index d3b5e19a..11880593 100644
--- a/src/subcommands/show_syntax_themes.rs
+++ b/src/subcommands/show_syntax_themes.rs
@@ -6,7 +6,7 @@ use crate::options::theme::is_light_syntax_theme;
use crate::utils;
use crate::utils::bat::output::{OutputType, PagingMode};
use clap::Parser;
-use std::io::{self, ErrorKind, Read, Write};
+use std::io::{self, ErrorKind, IsTerminal, Read, Write};
#[cfg(not(tarpaulin_include))]
pub fn show_syntax_themes() -> std::io::Result<()> {
@@ -21,7 +21,7 @@ pub fn show_syntax_themes() -> std::io::Result<()> {
.unwrap();
let mut writer = output_type.handle().unwrap();
- let stdin_data = if !atty::is(atty::Stream::Stdin) {
+ let stdin_data = if !io::stdin().is_terminal() {
let mut buf = Vec::new();
io::stdin().lock().read_to_end(&mut buf)?;
if !buf.is_empty() {
diff --git a/src/subcommands/show_themes.rs b/src/subcommands/show_themes.rs
index ba530b6a..76590761 100644
--- a/src/subcommands/show_themes.rs
+++ b/src/subcommands/show_themes.rs
@@ -1,4 +1,4 @@
-use std::io::{self, ErrorKind, Read};
+use std::io::{self, ErrorKind, IsTerminal, Read};
use crate::cli;
use crate::config;
@@ -17,7 +17,7 @@ pub fn show_themes(dark: bool, light: bool, computed_theme_is_light: bool) -> st
let mut input = DIFF.to_vec();
- if !atty::is(atty::Stream::Stdin) {
+ if !io::stdin().is_terminal() {
let mut buf = Vec::new();
io::stdin().lock().read_to_end(&mut buf)?;
if !buf.is_empty() {