Skip to content

Commit

Permalink
Remove atty
Browse files Browse the repository at this point in the history
  • Loading branch information
sbstp committed Jul 1, 2024
1 parent 932d73e commit 84acb99
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 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.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
10 changes: 5 additions & 5 deletions src/cmd/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::io::Cursor;
use std::io::{self, Cursor, IsTerminal};

use anyhow::{bail, Result};
use skim::prelude::{Key, SkimItemReader};
Expand Down Expand Up @@ -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")));
Expand Down Expand Up @@ -67,8 +67,8 @@ pub fn select_or_list_namespace(skim_options: &SkimOptions) -> Result<SelectResu
bail!("No namespaces found");
}

if atty::is(atty::Stream::Stdout) {
// NOTE: skim show the list of namespaces in reverse order
if io::stdout().is_terminal() {
// NOTE: skim shows the list of namespaces in reverse order
namespaces.reverse();
let item_reader = SkimItemReader::default();
let items = item_reader.of_bufread(Cursor::new(namespaces.join("\n")));
Expand Down
4 changes: 2 additions & 2 deletions src/settings.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::HashSet;
use std::fs::File;
use std::io::BufReader;
use std::io::{self, BufReader, IsTerminal};
use std::path::{Path, PathBuf};

use anyhow::{Context, Result};
Expand Down Expand Up @@ -159,7 +159,7 @@ pub enum ContextHeaderBehavior {
impl ContextHeaderBehavior {
pub fn should_print_headers(&self) -> bool {
match self {
ContextHeaderBehavior::Auto => atty::is(atty::Stream::Stdout),
ContextHeaderBehavior::Auto => io::stdout().is_terminal(),
ContextHeaderBehavior::Always => true,
ContextHeaderBehavior::Never => false,
}
Expand Down

0 comments on commit 84acb99

Please sign in to comment.