summaryrefslogtreecommitdiffstats
path: root/src/repl/handler.rs
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2023-03-11 21:45:34 +0800
committerGitHub <noreply@github.com>2023-03-11 21:45:34 +0800
commit4aab872ee1033df31827a35a1af2ee9f1ec2e2e7 (patch)
tree3e8f8dae818103fc551589d22b15c68068498921 /src/repl/handler.rs
parentcfb6ce6958751da5e13683ea07f42a5dbc4eae01 (diff)
downloadaichat-4aab872ee1033df31827a35a1af2ee9f1ec2e2e7.tar.gz
feat: add support for NO_COLOR (#67)
Diffstat (limited to 'src/repl/handler.rs')
-rw-r--r--src/repl/handler.rs23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/repl/handler.rs b/src/repl/handler.rs
index a7f4b08..159127c 100644
--- a/src/repl/handler.rs
+++ b/src/repl/handler.rs
@@ -50,50 +50,47 @@ impl ReplCmdHandler {
self.reply.borrow_mut().clear();
return Ok(());
}
- let highlight = self.config.lock().highlight;
- let light_theme = self.config.lock().light_theme;
let wg = WaitGroup::new();
let ret = render_stream(
&input,
&self.client,
- highlight,
- light_theme,
+ self.config.clone(),
true,
self.abort.clone(),
wg.clone(),
);
wg.wait();
let buffer = ret?;
- self.config.lock().save_message(&input, &buffer)?;
- self.config.lock().save_conversation(&input, &buffer)?;
+ self.config.read().save_message(&input, &buffer)?;
+ self.config.write().save_conversation(&input, &buffer)?;
*self.reply.borrow_mut() = buffer;
}
ReplCmd::SetRole(name) => {
- let output = self.config.lock().change_role(&name)?;
+ let output = self.config.write().change_role(&name)?;
print_now!("{}\n\n", output.trim_end());
}
ReplCmd::ClearRole => {
- self.config.lock().clear_role()?;
+ self.config.write().clear_role()?;
print_now!("\n");
}
ReplCmd::Prompt(prompt) => {
- self.config.lock().add_prompt(&prompt)?;
+ self.config.write().add_prompt(&prompt)?;
print_now!("\n");
}
ReplCmd::ViewInfo => {
- let output = self.config.lock().info()?;
+ let output = self.config.read().info()?;
print_now!("{}\n\n", output.trim_end());
}
ReplCmd::UpdateConfig(input) => {
- self.config.lock().update(&input)?;
+ self.config.write().update(&input)?;
print_now!("\n");
}
ReplCmd::StartConversation => {
- self.config.lock().start_conversation()?;
+ self.config.write().start_conversation()?;
print_now!("\n");
}
ReplCmd::EndConversatoin => {
- self.config.lock().end_conversation();
+ self.config.write().end_conversation();
print_now!("\n");
}
}