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

fix: replace atty with std::io::IsTerminal #3907

Merged
merged 1 commit into from
Mar 1, 2024
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
4 changes: 0 additions & 4 deletions 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 @@ -116,7 +116,6 @@ ark-std = { default-features = false, version = "0.4" }
assert_cmd = { version = "2.0" }
async-stream = { version = "0.3.5" }
async-trait = { version = "0.1.52" }
atty = { version = "0.2" }
axum = { version = "0.6" }
axum-server = { version = "0.4.7" }
base64 = { version = "0.21.2" }
Expand Down
1 change: 0 additions & 1 deletion crates/bin/pcli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ parallel = [
anyhow = {workspace = true}
ark-ff = {workspace = true, default-features = false}
async-stream = {workspace = true}
atty = {workspace = true}
base64 = {workspace = true}
bincode = {workspace = true}
blake2b_simd = {workspace = true}
Expand Down
7 changes: 5 additions & 2 deletions crates/bin/pcli/src/command/init.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use std::{io::Read, str::FromStr};
use std::{
io::{IsTerminal as _, Read},
str::FromStr,
};

use anyhow::Result;
use camino::Utf8PathBuf;
Expand Down Expand Up @@ -89,7 +92,7 @@ impl SoftKmsInitCmd {
// The `rpassword` crate doesn't support reading from stdin, so we check
// for an interactive session. We must support non-interactive use cases,
// for integration with other tooling.
if atty::is(atty::Stream::Stdin) {
if std::io::stdin().is_terminal() {
seed_phrase = rpassword::prompt_password("Enter seed phrase: ")?;
} else {
while let Ok(n_bytes) = std::io::stdin().lock().read_to_string(&mut seed_phrase)
Expand Down
3 changes: 2 additions & 1 deletion crates/bin/pcli/src/opt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use penumbra_proto::{
view::v1::{view_service_client::ViewServiceClient, view_service_server::ViewServiceServer},
};
use penumbra_view::ViewServer;
use std::io::IsTerminal as _;
use tracing_subscriber::EnvFilter;

#[derive(Debug, Parser)]
Expand All @@ -31,7 +32,7 @@ pub struct Opt {
impl Opt {
pub fn init_tracing(&mut self) {
tracing_subscriber::fmt()
.with_ansi(atty::is(atty::Stream::Stdout))
.with_ansi(std::io::stdout().is_terminal())
.with_env_filter(
EnvFilter::from_default_env()
// Without explicitly disabling the `r1cs` target, the ZK proof implementations
Expand Down
1 change: 0 additions & 1 deletion crates/bin/pclientd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ download-proving-keys = ["penumbra-proof-params/download-proving-keys"]
anyhow = {workspace = true}
async-stream = {workspace = true}
async-trait = {workspace = true}
atty = {workspace = true}
bytes = {workspace = true, features = ["serde"]}
camino = {workspace = true}
clap = {workspace = true, features = ["derive", "env"]}
Expand Down
4 changes: 3 additions & 1 deletion crates/bin/pclientd/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#![deny(clippy::unwrap_used)]
use std::io::IsTerminal as _;

use anyhow::Result;
use clap::Parser;
use tracing_subscriber::{prelude::*, EnvFilter};
Expand All @@ -8,7 +10,7 @@ use pclientd::Opt;
#[tokio::main]
async fn main() -> Result<()> {
let fmt_layer = tracing_subscriber::fmt::layer()
.with_ansi(atty::is(atty::Stream::Stdout))
.with_ansi(std::io::stdout().is_terminal())
.with_target(true);
let filter_layer = EnvFilter::try_from_default_env()
.or_else(|_| EnvFilter::try_new("info"))?
Expand Down
1 change: 0 additions & 1 deletion crates/bin/pd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ console-subscriber = {workspace = true}
metrics-tracing-context = {workspace = true}
metrics-util = "0.16.2"
clap = {workspace = true, features = ["derive", "env"]}
atty = {workspace = true}
fs_extra = "1.3.0"
axum-server = {workspace = true, features = ["tls-rustls"]}
zip = "0.6"
Expand Down
3 changes: 2 additions & 1 deletion crates/bin/pd/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#![deny(clippy::unwrap_used)]
#![recursion_limit = "512"]
use std::error::Error;
use std::io::IsTerminal as _;

use console_subscriber::ConsoleLayer;
use metrics_tracing_context::{MetricsLayer, TracingContextLayer};
Expand Down Expand Up @@ -46,7 +47,7 @@ async fn main() -> anyhow::Result<()> {
let metrics_layer = MetricsLayer::new();
// The `FmtLayer` is used to print to the console.
let fmt_layer = tracing_subscriber::fmt::layer()
.with_ansi(atty::is(atty::Stream::Stdout))
.with_ansi(std::io::stdout().is_terminal())
.with_target(true);
// The `EnvFilter` layer is used to filter events based on `RUST_LOG`.
let filter_layer = EnvFilter::try_from_default_env().or_else(|_| EnvFilter::try_new("info"))?;
Expand Down
1 change: 0 additions & 1 deletion tools/summonerd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ ark-groth16 = {workspace = true}
ark-serialize = {workspace = true}
askama = "0.11"
async-trait = {workspace = true}
atty = {workspace = true}
axum = {workspace = true}
bytes = {workspace = true}
camino = {workspace = true}
Expand Down
4 changes: 3 additions & 1 deletion tools/summonerd/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ use penumbra_proto::tools::summoning::v1::CeremonyCrs;
use penumbra_proto::Message;
use std::fs;
use std::fs::File;
use std::io;
use std::io::BufReader;
use std::io::BufWriter;
use std::io::IsTerminal as _;
use std::io::Read;
use std::net::SocketAddr;
use storage::Storage;
Expand Down Expand Up @@ -358,7 +360,7 @@ async fn main() -> Result<()> {
let console_layer = ConsoleLayer::builder().with_default_env().spawn();
// The `FmtLayer` is used to print to the console.
let fmt_layer = tracing_subscriber::fmt::layer()
.with_ansi(atty::is(atty::Stream::Stdout))
.with_ansi(io::stdout().is_terminal())
.with_target(true);
// The `EnvFilter` layer is used to filter events based on `RUST_LOG`.
let filter_layer = EnvFilter::try_from_default_env()
Expand Down
Loading