summaryrefslogtreecommitdiffstats
path: root/src/config.rs
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2023-03-08 17:13:11 +0800
committerGitHub <noreply@github.com>2023-03-08 17:13:11 +0800
commit2539e24fe9eadf69cb20b01d2303a99fa2e8a363 (patch)
treeb1b4b6a9e9df9d16870219a53b75a4456829a005 /src/config.rs
parentee812754313ebd16d34dff3d925afc4402c029fa (diff)
downloadaichat-2539e24fe9eadf69cb20b01d2303a99fa2e8a363.tar.gz
chore: improve code by getting prompt from config (#39)
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/config.rs b/src/config.rs
index 3b24a08..ec897b4 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -178,6 +178,13 @@ impl Config {
})
}
+ pub fn merge_prompt(&self, content: &str) -> String {
+ match self.get_prompt() {
+ Some(prompt) => format!("{}\n{content}", prompt.trim()),
+ None => content.to_string(),
+ }
+ }
+
pub fn info(&self) -> Result<String> {
let file_info = |path: &Path| {
let state = if path.exists() { "" } else { " ⚠️" };