Hi, in my PR on XDG support for macOS #124, I had not seen that colgrep's config dir was already derived from the data dir with a .parent(), see
|
/// Get the path to the config file |
|
pub fn get_config_path() -> Result<PathBuf> { |
|
let data_dir = get_colgrep_data_dir()?; |
|
// Go up one level from indices directory |
|
let parent = data_dir |
|
.parent() |
|
.context("Could not determine config directory")?; |
|
Ok(parent.join(CONFIG_FILE)) |
|
} |
So, since before my PR, the status has been that the config.json file is stored in ~/.local/share/colgrep/config.json. The cli help of the settings subcommand advertises the correct expected path ~/.config/colgrep/config.json with default XDG_CONFIG_DIR.
Granted, this is minor, but I'm considering opening a PR to introduce the same pattern as previously
pub fn xdg_config_home_or_default() -> Result<PathBuf> {
if let Ok(xdg) = std::env::var("XDG_CONFIG_HOME") {
if !xdg.is_empty() {
return Ok(PathBuf::from(xdg));
}
}
dirs::config_dir().context("Could not determine config directory")
}
and then replace the above code with
pub fn get_config_path() -> Result<PathBuf> {
Ok(xdg_config_home_or_default()?.join("colgrep").join(CONFIG_FILE))
}
(edit: I could also inline the 1st function into the 2nd one -- in case there's no reason the 1st one is reused)
Is it ok for you?
Cheers!
Hi, in my PR on XDG support for macOS #124, I had not seen that colgrep's config dir was already derived from the data dir with a
.parent(), seenext-plaid/colgrep/src/config.rs
Lines 507 to 515 in 7e772cf
So, since before my PR, the status has been that the config.json file is stored in
~/.local/share/colgrep/config.json. The cli help of thesettingssubcommand advertises the correct expected path~/.config/colgrep/config.jsonwith default XDG_CONFIG_DIR.Granted, this is minor, but I'm considering opening a PR to introduce the same pattern as previously
and then replace the above code with
(edit: I could also inline the 1st function into the 2nd one -- in case there's no reason the 1st one is reused)
Is it ok for you?
Cheers!