diff options
| author | sigoden <sigoden@gmail.com> | 2023-10-27 14:42:08 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-27 14:42:08 +0800 |
| commit | 0179bef80d3048929b1ce457f3f1447a3dd381e5 (patch) | |
| tree | 2fb96266dababb77bce02f15725f690811aea555 | |
| parent | 2b8b696b5afcccf7c014a96eb61e1aa0a675711a (diff) | |
| download | aichat-0179bef80d3048929b1ce457f3f1447a3dd381e5.tar.gz | |
chore: replace atty with is-terminal (#156)
| -rw-r--r-- | Cargo.lock | 25 | ||||
| -rw-r--r-- | Cargo.toml | 3 | ||||
| -rw-r--r-- | src/main.rs | 12 |
3 files changed, 9 insertions, 31 deletions
@@ -33,7 +33,6 @@ dependencies = [ "anyhow", "arboard", "async-trait", - "atty", "base64", "bincode", "bstr", @@ -167,17 +166,6 @@ dependencies = [ ] [[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" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -751,15 +739,6 @@ 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" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" @@ -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" diff --git a/src/main.rs b/src/main.rs index 573755b..65bc5f2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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), - } } } |
