Skip to content

Commit 0cc2b7d

Browse files
committed
chore: fix oversight in is_dir() as it doesnt exist ... is not dir, nor file
1 parent fa5da6b commit 0cc2b7d

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

config/src/lib.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,21 @@ fn config_home() -> PathBuf {
2020
}
2121
}
2222

23+
fn resolve_config_path(override_path: Option<PathBuf>) -> PathBuf {
24+
match override_path {
25+
Some(path) if path.is_dir() => path.join("config.toml"),
26+
Some(path) => path,
27+
None => config_home().join("config.toml"),
28+
}
29+
}
30+
2331
/// Goes around and initializes vital stuff for config to
2432
/// be read and written
2533
pub fn init_ring(
2634
// used to override a path, e.g -c / --config
2735
override_default_path: Option<PathBuf>,
2836
) {
29-
let maybe_file = override_default_path.unwrap_or_else(config_home);
30-
let config_path = if maybe_file.is_dir() {
31-
maybe_file.join("config.toml")
32-
} else {
33-
maybe_file.to_path_buf()
34-
};
37+
let config_path = resolve_config_path(override_default_path);
3538

3639
let inner_config = if config_path.is_file() {
3740
let raw = std::fs::read_to_string(&config_path)

0 commit comments

Comments
 (0)