From 7def9aef0179ad11ac29e401da8856e972c6ae7b Mon Sep 17 00:00:00 2001 From: sigoden Date: Mon, 6 Mar 2023 08:43:24 +0800 Subject: fix: combine pipe and cli args, disable highlight when pipe (#23) --- src/main.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index c7ae56e..0f12db5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -45,9 +45,13 @@ fn main() -> Result<()> { config.borrow_mut().role = role; let client = ChatGptClient::init(config.clone())?; if atty::isnt(atty::Stream::Stdin) { - let mut text = String::new(); - stdin().read_to_string(&mut text)?; - start_directive(client, config, &text) + let mut input = String::new(); + config.borrow_mut().highlight = false; + stdin().read_to_string(&mut input)?; + if let Some(text) = text { + input = format!("{text}\n{input}"); + } + start_directive(client, config, &input) } else { match text { Some(text) => start_directive(client, config, &text), -- cgit v1.2.3