From 7a60a3636780974dd4dfc7e73e4df0d5ab2f7f93 Mon Sep 17 00:00:00 2001 From: sigoden Date: Sun, 5 Mar 2023 05:50:30 +0800 Subject: feat: add `.info` command (#11) --- src/config.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/config.rs') 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 { + pub fn config_dir() -> Result { 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 { + 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 { + pub fn messages_file() -> Result { Self::local_file(MESSAGE_FILE_NAME) } -- cgit v1.2.3