diff options
author | Ivan Tham | 2021-06-17 16:52:41 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-06-19 07:37:15 +0000 |
commit | ca806d4f852e934651132fc9570a6110e30f646d (patch) | |
tree | 66e3fcfd6c018f435e23aee30aafd367ec39d7f2 /helix-term/src/main.rs | |
parent | 1c2585202145467f0fde7ad9c571e462081c3656 (diff) |
Refactor key into helix-view
Now also make use of Deserialize for Config.
Diffstat (limited to 'helix-term/src/main.rs')
-rw-r--r-- | helix-term/src/main.rs | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/helix-term/src/main.rs b/helix-term/src/main.rs index ef912480..12176910 100644 --- a/helix-term/src/main.rs +++ b/helix-term/src/main.rs @@ -1,10 +1,9 @@ +use anyhow::{Context, Error, Result}; use helix_term::application::Application; use helix_term::args::Args; use helix_term::config::Config; use std::path::PathBuf; -use anyhow::{Context, Result}; - fn setup_logging(logpath: PathBuf, verbosity: u64) -> Result<()> { let mut base_config = fern::Dispatch::new(); @@ -89,12 +88,11 @@ FLAGS: std::fs::create_dir_all(&conf_dir).ok(); } - let config = std::fs::read_to_string(conf_dir.join("config.toml")) - .ok() - .map(|s| toml::from_str(&s)) - .transpose()? - .or_else(|| Some(Config::default())) - .unwrap(); + let config = match std::fs::read_to_string(conf_dir.join("config.toml")) { + Ok(config) => toml::from_str(&config)?, + Err(err) if err.kind() == std::io::ErrorKind::NotFound => Config::default(), + Err(err) => return Err(Error::new(err)), + }; setup_logging(logpath, args.verbosity).context("failed to initialize logging")?; |