chore: replace atty with is-terminal (#156)

pull/157/head
sigoden 8 months ago committed by GitHub
parent 2b8b696b5a
commit 0179bef80d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

25
Cargo.lock generated

@ -33,7 +33,6 @@ dependencies = [
"anyhow",
"arboard",
"async-trait",
"atty",
"base64",
"bincode",
"bstr",
@ -166,17 +165,6 @@ dependencies = [
"syn 2.0.38",
]
[[package]]
name = "atty"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [
"hermit-abi 0.1.19",
"libc",
"winapi",
]
[[package]]
name = "autocfg"
version = "1.1.0"
@ -749,15 +737,6 @@ version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
[[package]]
name = "hermit-abi"
version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
dependencies = [
"libc",
]
[[package]]
name = "hermit-abi"
version = "0.3.3"
@ -917,7 +896,7 @@ version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b"
dependencies = [
"hermit-abi 0.3.3",
"hermit-abi",
"rustix",
"windows-sys 0.48.0",
]
@ -1112,7 +1091,7 @@ version = "1.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43"
dependencies = [
"hermit-abi 0.3.3",
"hermit-abi",
"libc",
]

@ -18,7 +18,7 @@ dirs = "5.0.0"
eventsource-stream = "0.2.3"
futures-util = "0.3.26"
inquire = "0.6.2"
is-terminal = "0.4.4"
is-terminal = "0.4.9"
reedline = "0.21.0"
serde = { version = "1.0.152", features = ["derive"] }
serde_json = "1.0.93"
@ -27,7 +27,6 @@ tokio = { version = "1.26.0", features = ["full"] }
crossbeam = "0.8.2"
crossterm = "0.26.1"
chrono = "0.4.23"
atty = "0.2.14"
unicode-width = "0.1.10"
bincode = "1.3.3"
ctrlc = "3.2.5"

@ -71,18 +71,18 @@ fn main() -> Result<()> {
}
let no_stream = cli.no_stream;
let client = init_client(config.clone())?;
if atty::isnt(atty::Stream::Stdin) {
if stdin().is_terminal() {
match text {
Some(text) => start_directive(client.as_ref(), &config, &text, no_stream),
None => start_interactive(config),
}
} else {
let mut input = String::new();
stdin().read_to_string(&mut input)?;
if let Some(text) = text {
input = format!("{text}\n{input}");
}
start_directive(client.as_ref(), &config, &input, no_stream)
} else {
match text {
Some(text) => start_directive(client.as_ref(), &config, &text, no_stream),
None => start_interactive(config),
}
}
}

Loading…
Cancel
Save