summaryrefslogtreecommitdiffstats
path: root/src/config.rs
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2023-03-05 05:50:30 +0800
committerGitHub <noreply@github.com>2023-03-05 05:50:30 +0800
commit7a60a3636780974dd4dfc7e73e4df0d5ab2f7f93 (patch)
tree741047ff5cadb63e6ee647e1066256fdbf2d2db5 /src/config.rs
parenta055d4bee697c2dbf600afbd768e840b0f040247 (diff)
downloadaichat-7a60a3636780974dd4dfc7e73e4df0d5ab2f7f93.tar.gz
feat: add `.info` command (#11)
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/config.rs b/src/config.rs
index 1c6abc5..b5220dd 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -55,7 +55,7 @@ impl Config {
self.roles.iter().find(|v| v.name == name).cloned()
}
- pub fn local_file(name: &str) -> Result<PathBuf> {
+ pub fn config_dir() -> Result<PathBuf> {
let env_name = format!(
"{}_CONFIG_DIR",
env!("CARGO_CRATE_NAME").to_ascii_uppercase()
@@ -70,6 +70,11 @@ impl Config {
anyhow!("Failed to create config dir at {}, {err}", path.display())
})?;
}
+ Ok(path)
+ }
+
+ pub fn local_file(name: &str) -> Result<PathBuf> {
+ let mut path = Self::config_dir()?;
path.push(name);
Ok(path)
}
@@ -117,7 +122,7 @@ impl Config {
Self::local_file(HISTORY_FILE_NAME)
}
- fn messages_file() -> Result<PathBuf> {
+ pub fn messages_file() -> Result<PathBuf> {
Self::local_file(MESSAGE_FILE_NAME)
}