summaryrefslogtreecommitdiffstats
path: root/src/repl/handler.rs
diff options
context:
space:
mode:
authorAnthony Rubick <68485672+AnthonyMichaelTDM@users.noreply.github.com>2023-07-09 20:07:09 -0700
committerGitHub <noreply@github.com>2023-07-10 11:07:09 +0800
commit97fc7de6754c8b5c383d7d5e3f9e26b3bbfb08fb (patch)
treec19390877425fa50049761e8ee6bc93f21c46f56 /src/repl/handler.rs
parentec51b84290215d11d5045de8baa9b89f2447b1e9 (diff)
downloadaichat-97fc7de6754c8b5c383d7d5e3f9e26b3bbfb08fb.tar.gz
fix: minor code cleanup and pedantic lints (#134)
Diffstat (limited to 'src/repl/handler.rs')
-rw-r--r--src/repl/handler.rs30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/repl/handler.rs b/src/repl/handler.rs
index 495413c..2057b8b 100644
--- a/src/repl/handler.rs
+++ b/src/repl/handler.rs
@@ -24,6 +24,7 @@ pub enum ReplCmd {
Copy,
}
+#[allow(clippy::module_name_repetitions)]
pub struct ReplCmdHandler {
client: ChatGptClient,
config: SharedConfig,
@@ -32,6 +33,7 @@ pub struct ReplCmdHandler {
}
impl ReplCmdHandler {
+ #[allow(clippy::unnecessary_wraps)]
pub fn init(
client: ChatGptClient,
config: SharedConfig,
@@ -58,7 +60,7 @@ impl ReplCmdHandler {
let ret = render_stream(
&input,
&self.client,
- self.config.clone(),
+ &self.config,
true,
self.abort.clone(),
wg.clone(),
@@ -113,6 +115,7 @@ impl ReplCmdHandler {
}
}
+#[allow(clippy::module_name_repetitions)]
pub struct ReplyStreamHandler {
sender: Option<Sender<ReplyStreamEvent>>,
buffer: String,
@@ -154,22 +157,19 @@ impl ReplyStreamHandler {
}
pub fn done(&mut self) -> Result<()> {
- match self.sender.as_ref() {
- Some(tx) => {
- let ret = tx
- .send(ReplyStreamEvent::Done)
- .with_context(|| "Failed to send StreamEvent:Done");
- self.safe_ret(ret)?;
+ if let Some(tx) = self.sender.as_ref() {
+ let ret = tx
+ .send(ReplyStreamEvent::Done)
+ .with_context(|| "Failed to send StreamEvent:Done");
+ self.safe_ret(ret)?;
+ } else {
+ if !self.buffer.ends_with('\n') {
+ print_now!("\n");
}
- None => {
- if !self.buffer.ends_with('\n') {
- print_now!("\n")
- }
- if self.repl {
+ if self.repl {
+ print_now!("\n");
+ if cfg!(macos) {
print_now!("\n");
- if cfg!(macos) {
- print_now!("\n")
- }
}
}
}