From 84acb9981837dd7da40e8c1766aa7aeeafa7a5a4 Mon Sep 17 00:00:00 2001 From: Simon Bernier St-Pierre Date: Sun, 30 Jun 2024 20:23:48 -0400 Subject: [PATCH] Remove atty --- Cargo.lock | 1 - Cargo.toml | 1 - src/cmd/mod.rs | 10 +++++----- src/settings.rs | 4 ++-- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 27dad9c9..a47ca164 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -708,7 +708,6 @@ version = "0.23.0" dependencies = [ "anyhow", "attohttpc", - "atty", "cfg-if", "clap 4.5.8", "dirs", diff --git a/Cargo.toml b/Cargo.toml index cc61c40c..478118c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,6 @@ version = "0.23.0" [dependencies] anyhow = "1" -atty = "0.2" clap = { version = "4.5.8", features = ["derive"] } cfg-if = "1" dirs = "5" diff --git a/src/cmd/mod.rs b/src/cmd/mod.rs index 95b86daf..87d4a58e 100644 --- a/src/cmd/mod.rs +++ b/src/cmd/mod.rs @@ -1,4 +1,4 @@ -use std::io::Cursor; +use std::io::{self, Cursor, IsTerminal}; use anyhow::{bail, Result}; use skim::prelude::{Key, SkimItemReader}; @@ -36,8 +36,8 @@ pub fn select_or_list_context(skim_options: &SkimOptions, installed: &mut Instal return Ok(SelectResult::Selected(context_names[0].clone())); } - if atty::is(atty::Stream::Stdout) { - // NOTE: skim show the list of context names in reverse order + if io::stdout().is_terminal() { + // NOTE: skim shows the list of context names in reverse order context_names.reverse(); let item_reader = SkimItemReader::default(); let items = item_reader.of_bufread(Cursor::new(context_names.join("\n"))); @@ -67,8 +67,8 @@ pub fn select_or_list_namespace(skim_options: &SkimOptions) -> Result bool { match self { - ContextHeaderBehavior::Auto => atty::is(atty::Stream::Stdout), + ContextHeaderBehavior::Auto => io::stdout().is_terminal(), ContextHeaderBehavior::Always => true, ContextHeaderBehavior::Never => false, }