summaryrefslogtreecommitdiffstats
path: root/src/config
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2024-03-02 22:02:29 +0800
committerGitHub <noreply@github.com>2024-03-02 22:02:29 +0800
commitb2f86f2899b79b291eb56435f99402509105b7ec (patch)
treeeaba5d76d05289c25f2f7e027c05c2fa3aec9928 /src/config
parent3c16aff59145134885f32056fa3be9bd6bed2cce (diff)
downloadaichat-b2f86f2899b79b291eb56435f99402509105b7ec.tar.gz
refactor: auto_copy works when executing command (#328)
Diffstat (limited to 'src/config')
-rw-r--r--src/config/mod.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/config/mod.rs b/src/config/mod.rs
index 6b99483..cbf1020 100644
--- a/src/config/mod.rs
+++ b/src/config/mod.rs
@@ -11,7 +11,7 @@ use crate::client::{
Model, OpenAIClient, SendData,
};
use crate::render::{MarkdownRender, RenderOptions};
-use crate::utils::{get_env_name, light_theme_from_colorfgbg, now, render_prompt};
+use crate::utils::{get_env_name, light_theme_from_colorfgbg, now, render_prompt, set_text};
use anyhow::{anyhow, bail, Context, Result};
use inquire::{Confirm, Select, Text};
@@ -247,6 +247,12 @@ impl Config {
.with_context(|| "Failed to save message")
}
+ pub fn maybe_copy(&self, text: &str) {
+ if self.auto_copy {
+ let _ = set_text(text);
+ }
+ }
+
pub fn config_file() -> Result<PathBuf> {
Self::local_path(CONFIG_FILE_NAME)
}