diff options
| author | sigoden <sigoden@gmail.com> | 2024-04-09 07:17:02 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-09 07:17:02 +0800 |
| commit | 2738988fc47f0f068b6c78e556760a0dbca8d932 (patch) | |
| tree | 7943fea61bc0650aa6fb1b6baeebe5d8a5a156b6 /src/repl/mod.rs | |
| parent | 3a0cafebd9965eec55864a0864684223d2fb3d8d (diff) | |
| download | aichat-2738988fc47f0f068b6c78e556760a0dbca8d932.tar.gz | |
feat: add `ctrlc_exit` option to control REPL exit by ctrl+c (#391)
Diffstat (limited to 'src/repl/mod.rs')
| -rw-r--r-- | src/repl/mod.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/repl/mod.rs b/src/repl/mod.rs index 1b96d3b..cc642cc 100644 --- a/src/repl/mod.rs +++ b/src/repl/mod.rs @@ -103,6 +103,7 @@ impl Repl { self.banner(); let mut already_ctrlc = false; + let ctrlc_exit = self.config.read().ctrlc_exit; loop { if self.abort.aborted_ctrld() { @@ -117,8 +118,8 @@ impl Repl { already_ctrlc = false; self.abort.reset(); match self.handle(&line) { - Ok(quit) => { - if quit { + Ok(exit) => { + if exit { break; } } @@ -130,7 +131,7 @@ impl Repl { } Ok(Signal::CtrlC) => { self.abort.set_ctrlc(); - if already_ctrlc { + if already_ctrlc && ctrlc_exit { break; } already_ctrlc = true; |
