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

chore: Remove direct dependency on atty #222

Merged
merged 1 commit into from
Apr 22, 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
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 @@ -33,7 +33,6 @@ ic-agent = { git = "https://github.com/dfinity/agent-rs", rev = "73da09c1c553193
ic-identity-hsm = { git = "https://github.com/dfinity/agent-rs", rev = "73da09c1c553193c46d7edef73c8c20beaa8498c", optional = true }

anyhow = "1.0.34"
atty = "0.2.14"
base64 = "0.13.0"
bip32 = "0.4.0"
clap = { version = "3.1.18", features = ["derive", "cargo"] }
Expand Down
6 changes: 3 additions & 3 deletions src/commands/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use crate::lib::{
AnyhowResult, AuthInfo,
};
use anyhow::{anyhow, bail, Context};
use atty::Stream;
use candid::{CandidType, Principal};
use clap::Parser;
use ic_agent::agent::Transport;
Expand All @@ -14,6 +13,7 @@ use ic_agent::{
};
use icp_ledger::{Subaccount, Tokens};
use serde::{Deserialize, Serialize};
use std::io::IsTerminal;
use std::path::PathBuf;
use std::str::FromStr;

Expand Down Expand Up @@ -67,7 +67,7 @@ pub struct SendOpts {
pub async fn exec(opts: SendOpts, fetch_root_key: bool) -> AnyhowResult {
let file_name = if let Some(file_name) = &opts.file_name {
file_name.as_path()
} else if atty::isnt(Stream::Stdin) {
} else if !std::io::stdin().is_terminal() {
"-".as_ref()
} else {
bail!("File name must be provided if not being piped")
Expand Down Expand Up @@ -157,7 +157,7 @@ async fn send(message: &Ingress, opts: &SendOpts) -> AnyhowResult {
}

if message.call_type == "update" && !opts.yes {
if !atty::is(Stream::Stdin) {
if !std::io::stdin().is_terminal() {
eprintln!("Cannot confirm y/n if the input is being piped.");
eprintln!("To confirm sending this message, rerun `quill send` with the `-y` flag.");
std::process::exit(1);
Expand Down
Loading