summaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2023-03-06 08:43:24 +0800
committerGitHub <noreply@github.com>2023-03-06 08:43:24 +0800
commit7def9aef0179ad11ac29e401da8856e972c6ae7b (patch)
tree7dcbc02357ec2ffd97a96df4c8c6739de4c8518d /src/main.rs
parentc5a2f4603c3c3eb7995f4e77453ab8ca50ff88b8 (diff)
downloadaichat-7def9aef0179ad11ac29e401da8856e972c6ae7b.tar.gz
fix: combine pipe and cli args, disable highlight when pipe (#23)
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs10
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),