diff options
| author | sigoden <sigoden@gmail.com> | 2023-03-06 08:43:24 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-06 08:43:24 +0800 |
| commit | 7def9aef0179ad11ac29e401da8856e972c6ae7b (patch) | |
| tree | 7dcbc02357ec2ffd97a96df4c8c6739de4c8518d | |
| parent | c5a2f4603c3c3eb7995f4e77453ab8ca50ff88b8 (diff) | |
| download | aichat-7def9aef0179ad11ac29e401da8856e972c6ae7b.tar.gz | |
fix: combine pipe and cli args, disable highlight when pipe (#23)
| -rw-r--r-- | src/main.rs | 10 |
1 files changed, 7 insertions, 3 deletions
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), |
