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 /src/main.rs | |
| parent | 2b8b696b5afcccf7c014a96eb61e1aa0a675711a (diff) | |
| download | aichat-0179bef80d3048929b1ce457f3f1447a3dd381e5.tar.gz | |
chore: replace atty with is-terminal (#156)
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 12 |
1 files changed, 6 insertions, 6 deletions
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), - } } } |
