Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the is-terminal crate instead of atty #2530

Merged
merged 1 commit into from
Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ application = [
# Mainly for developers that want to iterate quickly
# Be aware that the included features might change in the future
minimal-application = [
"atty",
"is-terminal",
"clap",
"dirs",
"paging",
Expand All @@ -41,7 +41,7 @@ regex-onig = ["syntect/regex-onig"] # Use the "oniguruma" regex engine
regex-fancy = ["syntect/regex-fancy"] # Use the rust-only "fancy-regex" engine

[dependencies]
atty = { version = "0.2.14", optional = true }
is-terminal = { version = "0.4.4", optional = true }
nu-ansi-term = "0.47.0"
ansi_colours = "^1.2"
bincode = "1.0"
Expand Down
6 changes: 3 additions & 3 deletions src/bin/bat/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::collections::HashSet;
use std::env;
use std::path::{Path, PathBuf};

use atty::{self, Stream};
use is_terminal::IsTerminal;

use crate::{
clap_app,
Expand Down Expand Up @@ -40,7 +40,7 @@ impl App {
#[cfg(windows)]
let _ = nu_ansi_term::enable_ansi_support();

let interactive_output = atty::is(Stream::Stdout);
let interactive_output = std::io::stdout().is_terminal();

Ok(App {
matches: Self::matches(interactive_output)?,
Expand Down Expand Up @@ -104,7 +104,7 @@ impl App {
// If we are reading from stdin, only enable paging if we write to an
// interactive terminal and if we do not *read* from an interactive
// terminal.
if self.interactive_output && !atty::is(Stream::Stdin) {
if self.interactive_output && std::io::stdin().is_terminal() {
PagingMode::QuitIfOneScreen
} else {
PagingMode::Never
Expand Down