From 188e753675b5c4be6744c0e6fc709194a0b56705 Mon Sep 17 00:00:00 2001 From: Sharif Haason Date: Sun, 4 Dec 2022 21:42:44 -0500 Subject: Replace `atty` with `is-terminal` --- Cargo.lock | 100 +++++++++++++++---------------------------------------- Cargo.toml | 2 +- src/bin/hexyl.rs | 4 +-- 3 files changed, 30 insertions(+), 76 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d5aaa3c..cf900ea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -25,9 +25,9 @@ checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6" [[package]] name = "assert_cmd" -version = "2.0.6" +version = "2.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba45b8163c49ab5f972e59a8a5a03b6d2972619d486e19ec9fe744f7c2753d3c" +checksum = "fa3d466004a8b4cb1bc34044240a2fd29d17607e2e3bd613eb44fd48e8100da3" dependencies = [ "bstr", "doc-comment", @@ -37,17 +37,6 @@ dependencies = [ "wait-timeout", ] -[[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" @@ -80,9 +69,9 @@ checksum = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4" [[package]] name = "clap" -version = "4.0.27" +version = "4.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0acbd8d28a0a60d7108d7ae850af6ba34cf2d1257fc646980e5f97ce14275966" +checksum = "4d63b9e9c07271b9957ad22c173bae2a4d9a81127680962039296abcd2f8251d" dependencies = [ "bitflags", "clap_lex", @@ -186,15 +175,6 @@ dependencies = [ "num-traits", ] -[[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.2.6" @@ -211,9 +191,9 @@ dependencies = [ "anstyle", "anyhow", "assert_cmd", - "atty", "clap", "const_format", + "is-terminal", "libc", "predicates", "pretty_assertions", @@ -223,15 +203,9 @@ dependencies = [ [[package]] name = "io-lifetimes" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59ce5ef949d49ee85593fc4d3f3f95ad61657076395cbbce23e2121fc5542074" - -[[package]] -name = "io-lifetimes" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e394faa0efb47f9f227f1cd89978f854542b318a6f64fa695489c9c993056656" +checksum = "46112a93252b123d31a119a8d1a1ac19deac4fac6e0e8b0df58f0d4e5870e63c" dependencies = [ "libc", "windows-sys", @@ -239,13 +213,13 @@ dependencies = [ [[package]] name = "is-terminal" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aae5bc6e2eb41c9def29a3e0f1306382807764b9b53112030eff57435667352d" +checksum = "927609f78c2913a6f6ac3c27a4fe87f43e2a35367c0c4b0f8265e8f49a104330" dependencies = [ - "hermit-abi 0.2.6", - "io-lifetimes 1.0.2", - "rustix 0.36.3", + "hermit-abi", + "io-lifetimes", + "rustix", "windows-sys", ] @@ -260,15 +234,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.137" +version = "0.2.138" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" - -[[package]] -name = "linux-raw-sys" -version = "0.0.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4d2456c373231a208ad294c33dc5bff30051eafd954cd4caae83a712b12854d" +checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8" [[package]] name = "linux-raw-sys" @@ -320,9 +288,9 @@ dependencies = [ [[package]] name = "predicates" -version = "2.1.3" +version = "2.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed6bd09a7f7e68f3f0bf710fb7ab9c4615a488b58b5f653382a687701e458c92" +checksum = "f54fc5dc63ed3bbf19494623db4f3af16842c0d975818e469022d09e53f0aa05" dependencies = [ "difflib", "float-cmp", @@ -403,37 +371,23 @@ checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" [[package]] name = "rustix" -version = "0.35.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "727a1a6d65f786ec22df8a81ca3121107f235970dc1705ed681d3e6e8b9cd5f9" -dependencies = [ - "bitflags", - "errno", - "io-lifetimes 0.7.5", - "libc", - "linux-raw-sys 0.0.46", - "windows-sys", -] - -[[package]] -name = "rustix" -version = "0.36.3" +version = "0.36.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b1fbb4dfc4eb1d390c02df47760bb19a84bb80b301ecc947ab5406394d8223e" +checksum = "cb93e85278e08bb5788653183213d3a60fc242b10cb9be96586f5a73dcb67c23" dependencies = [ "bitflags", "errno", - "io-lifetimes 1.0.2", + "io-lifetimes", "libc", - "linux-raw-sys 0.1.3", + "linux-raw-sys", "windows-sys", ] [[package]] name = "serde" -version = "1.0.147" +version = "1.0.148" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965" +checksum = "e53f64bb4ba0191d6d0676e1b141ca55047d83b74f5607e6d8eb88126c52c2dc" [[package]] name = "strsim" @@ -443,9 +397,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "1.0.103" +version = "1.0.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d" +checksum = "60b9b43d45702de4c839cb9b51d9f529c5dd26a4aff255b42b1ebc03e88ee908" dependencies = [ "proc-macro2", "quote", @@ -463,11 +417,11 @@ dependencies = [ [[package]] name = "terminal_size" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ca90c434fd12083d1a6bdcbe9f92a14f96c8a1ba600ba451734ac334521f7a" +checksum = "cb20089a8ba2b69debd491f8d2d023761cbf196e999218c591fa1e7e15a21907" dependencies = [ - "rustix 0.35.13", + "rustix", "windows-sys", ] diff --git a/Cargo.toml b/Cargo.toml index 4f91eb3..43bafde 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,8 +13,8 @@ edition = "2021" [dependencies] anstyle = "0.2.5" anyhow = "1.0" -atty = "0.2" const_format = "0.2" +is-terminal = "0.4" libc = "0.2" thiserror = "1.0" terminal_size = "0.2" diff --git a/src/bin/hexyl.rs b/src/bin/hexyl.rs index 4b4cf5b..e2bcd6d 100644 --- a/src/bin/hexyl.rs +++ b/src/bin/hexyl.rs @@ -9,7 +9,7 @@ use std::num::{NonZeroI64, NonZeroU64, NonZeroU8}; use clap::builder::ArgPredicate; use clap::{crate_name, crate_version, Arg, ArgAction, ColorChoice, Command}; -use atty::Stream; +use is_terminal::IsTerminal; use anyhow::{anyhow, Context, Error as AnyhowError}; @@ -281,7 +281,7 @@ fn run() -> Result<(), AnyhowError> { let show_color = match matches.get_one::("color").map(String::as_ref) { Some("never") => false, - Some("auto") => atty::is(Stream::Stdout), + Some("auto") => std::io::stdout().is_terminal(), _ => true, }; -- cgit v1.2.3 From fcd09ffface2500572d15ae2983dbe9762d29e06 Mon Sep 17 00:00:00 2001 From: Sharif Haason Date: Sun, 4 Dec 2022 21:43:03 -0500 Subject: Relax `anstyle` version --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 43bafde..a8bc92e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ version = "0.10.0" edition = "2021" [dependencies] -anstyle = "0.2.5" +anstyle = "0.2" anyhow = "1.0" const_format = "0.2" is-terminal = "0.4" -- cgit v1.2.3 From 571312dd6ea6a12ab0e4263d593ba8b9ccf21ef2 Mon Sep 17 00:00:00 2001 From: Sharif Haason Date: Sun, 4 Dec 2022 21:48:10 -0500 Subject: Replace `libc` with `rustix` --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/input.rs | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cf900ea..23512a2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -194,9 +194,9 @@ dependencies = [ "clap", "const_format", "is-terminal", - "libc", "predicates", "pretty_assertions", + "rustix", "terminal_size", "thiserror", ] diff --git a/Cargo.toml b/Cargo.toml index a8bc92e..84993a4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ anstyle = "0.2" anyhow = "1.0" const_format = "0.2" is-terminal = "0.4" -libc = "0.2" +rustix = "0.36" thiserror = "1.0" terminal_size = "0.2" diff --git a/src/input.rs b/src/input.rs index 1e6fb06..d6d9f5f 100644 --- a/src/input.rs +++ b/src/input.rs @@ -2,6 +2,8 @@ use std::convert::TryFrom; use std::fs; use std::io::{self, copy, sink, Read, Seek, SeekFrom}; +use rustix::io::Errno; + pub enum Input<'a> { File(fs::File), Stdin(io::StdinLock<'a>), @@ -35,8 +37,7 @@ impl<'a> Seek for Input<'a> { match *self { Input::File(ref mut file) => { let seek_res = file.seek(pos); - if let Err(Some(libc::ESPIPE)) = seek_res.as_ref().map_err(|err| err.raw_os_error()) - { + if let Err(Some(Errno::SPIPE)) = seek_res.as_ref().map_err(Errno::from_io_error) { try_skip( file, pos, -- cgit v1.2.3