aboutsummaryrefslogtreecommitdiffstats
path: root/mumctl/src/main.rs
diff options
context:
space:
mode:
authorGustav Sörnäs <gustav@sornas.net>2021-05-25 21:00:18 +0200
committerGitHub <noreply@github.com>2021-05-25 21:00:18 +0200
commitea8b1906e14c3b319d3ad184b6d7cfc507c23b4f (patch)
tree6fb5dd74ab3ca333591778bcf91d45fe988c2cd4 /mumctl/src/main.rs
parent4473bdd1536699c53f27085dd7d4d5d14dd93508 (diff)
parenta5a7a524981005c63931b62567ffca355965b2ba (diff)
downloadmum-ea8b1906e14c3b319d3ad184b6d7cfc507c23b4f.tar.gz
Merge pull request #85 from mum-rs/config-paths
remove cfg_exists, pass paths explicitly
Diffstat (limited to 'mumctl/src/main.rs')
-rw-r--r--mumctl/src/main.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/mumctl/src/main.rs b/mumctl/src/main.rs
index 5abed50..191a973 100644
--- a/mumctl/src/main.rs
+++ b/mumctl/src/main.rs
@@ -211,7 +211,7 @@ fn main() {
}
}
fn match_opt() -> Result<(), Error> {
- let mut config = config::read_default_cfg()?;
+ let mut config = config::read_cfg(&config::default_cfg_path())?;
let opt = Mum::from_args();
match opt.command {
@@ -351,18 +351,19 @@ fn match_opt() -> Result<(), Error> {
}
}
- if !config::cfg_exists() {
+ let config_path = config::default_cfg_path();
+ if !config_path.exists() {
println!(
"Config file not found. Create one in {}? [Y/n]",
- config::default_cfg_path().display(),
+ config_path.display(),
);
let stdin = std::io::stdin();
let response = stdin.lock().lines().next();
if let Some(Ok(true)) = response.map(|e| e.map(|e| &e == "Y")) {
- config.write_default_cfg(true)?;
+ config.write(&config_path, true)?;
}
} else {
- config.write_default_cfg(false)?;
+ config.write(&config_path, false)?;
}
Ok(())
}