From 0179bef80d3048929b1ce457f3f1447a3dd381e5 Mon Sep 17 00:00:00 2001 From: sigoden Date: Fri, 27 Oct 2023 14:42:08 +0800 Subject: chore: replace atty with is-terminal (#156) --- src/main.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/main.rs') 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), - } } } -- cgit v1.2.3