summaryrefslogtreecommitdiffstats
path: root/src/repl/mod.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/mod.rs
parentcfb6ce6958751da5e13683ea07f42a5dbc4eae01 (diff)
downloadaichat-4aab872ee1033df31827a35a1af2ee9f1ec2e2e7.tar.gz
feat: add support for NO_COLOR (#67)
Diffstat (limited to 'src/repl/mod.rs')
-rw-r--r--src/repl/mod.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/repl/mod.rs b/src/repl/mod.rs
index f40a011..f44a5bf 100644
--- a/src/repl/mod.rs
+++ b/src/repl/mod.rs
@@ -1,12 +1,12 @@
mod abort;
mod handler;
+mod highlighter;
mod init;
mod prompt;
pub use self::abort::*;
pub use self::handler::*;
pub use self::init::Repl;
-use self::prompt::ReplPrompt;
use crate::client::ChatGptClient;
use crate::config::SharedConfig;
@@ -35,8 +35,7 @@ pub const REPL_COMMANDS: [(&str, &str); 11] = [
impl Repl {
pub fn run(&mut self, client: ChatGptClient, config: SharedConfig) -> Result<()> {
let abort = AbortSignal::new();
- let handler = ReplCmdHandler::init(client, config.clone(), abort.clone())?;
- let prompt = ReplPrompt::new(config);
+ let handler = ReplCmdHandler::init(client, config, abort.clone())?;
print_now!("Welcome to aichat {}\n", env!("CARGO_PKG_VERSION"));
print_now!("Type \".help\" for more information.\n");
let mut already_ctrlc = false;
@@ -48,7 +47,7 @@ impl Repl {
if abort.aborted_ctrlc() && !already_ctrlc {
already_ctrlc = true;
}
- let sig = self.editor.read_line(&prompt);
+ let sig = self.editor.read_line(&self.prompt);
match sig {
Ok(Signal::Success(line)) => {
already_ctrlc = false;
@@ -117,7 +116,8 @@ impl Repl {
handler.handle(ReplCmd::ViewInfo)?;
}
".set" => {
- handler.handle(ReplCmd::UpdateConfig(args.unwrap_or_default().to_string()))?
+ handler.handle(ReplCmd::UpdateConfig(args.unwrap_or_default().to_string()))?;
+ self.prompt.sync_config();
}
".prompt" => {
let text = args.unwrap_or_default().to_string();