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

cli: switch from atty crate to crossterm #783

Merged
merged 1 commit into from
Nov 24, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -34,7 +34,6 @@ harness = false
members = ["lib"]

[dependencies]
atty = "0.2.14"
chrono = { version = "0.4.23", default-features = false, features = ["std", "clock"] }
clap = { version = "4.0.26", features = ["derive", "deprecated"] }
clap_complete = "4.0.5"
Expand Down
1 change: 1 addition & 0 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ notice = "warn"
# output a note when they are encountered.
ignore = [
#"RUSTSEC-0000-0000",
"RUSTSEC-2021-0145",
]
# Threshold for security vulnerabilities, any vulnerability with a CVSS score
# lower than the range specified will be ignored. Note that ignored advisories
Expand Down
10 changes: 5 additions & 5 deletions src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::path::{Path, PathBuf};
use std::str::FromStr;
use std::{fmt, io};

use atty::Stream;
use crossterm::tty::IsTty;
use jujutsu_lib::settings::UserSettings;

use crate::formatter::{Formatter, FormatterFactory};
Expand Down Expand Up @@ -80,7 +80,7 @@ fn use_color(choice: ColorChoice) -> bool {
match choice {
ColorChoice::Always => true,
ColorChoice::Never => false,
ColorChoice::Auto => atty::is(Stream::Stdout),
ColorChoice::Auto => io::stdout().is_tty(),
}
}

Expand Down Expand Up @@ -154,7 +154,7 @@ impl Ui {
/// Whether continuous feedback should be displayed for long-running
/// operations
pub fn use_progress_indicator(&self) -> bool {
self.settings().use_progress_indicator() && atty::is(Stream::Stdout)
self.settings().use_progress_indicator() && io::stdout().is_tty()
}

pub fn write(&mut self, text: &str) -> io::Result<()> {
Expand Down Expand Up @@ -208,7 +208,7 @@ impl Ui {
}

pub fn prompt(&mut self, prompt: &str) -> io::Result<String> {
if !atty::is(Stream::Stdout) {
if !io::stdout().is_tty() {
return Err(io::Error::new(
io::ErrorKind::Unsupported,
"Cannot prompt for input since the output is not connected to a terminal",
Expand All @@ -222,7 +222,7 @@ impl Ui {
}

pub fn prompt_password(&mut self, prompt: &str) -> io::Result<String> {
if !atty::is(Stream::Stdout) {
if !io::stdout().is_tty() {
return Err(io::Error::new(
io::ErrorKind::Unsupported,
"Cannot prompt for input since the output is not connected to a terminal",
Expand Down