summaryrefslogtreecommitdiffstats
path: root/src/config.rs
diff options
context:
space:
mode:
authorRicky <Ricky@Hosfelt.io>2018-11-01 15:48:56 +0000
committerDavid Peter <sharkdp@users.noreply.github.com>2018-11-04 11:19:49 +0100
commit558134f6c8a9c3601c48863a45f5c3bf7f125972 (patch)
tree58b5c8e29726e8b66d3359d103eaf5c47ffc72fd /src/config.rs
parent1dd57e6d7e0e7325c49bca8baac610c5312922a9 (diff)
Changed to unwrap methods, added integration tests
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/config.rs b/src/config.rs
index 8701e068..340e532a 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -9,17 +9,11 @@ use dirs::PROJECT_DIRS;
use util::transpose;
pub fn config_file() -> PathBuf {
- match env::var("BAT_CONFIG_PATH") {
- Ok(env_path) => {
- let env_path_buf = PathBuf::from(env_path);
- if env_path_buf.is_file() {
- return env_path_buf;
- } else {
- return PROJECT_DIRS.config_dir().join("config");
- }
- }
- Err(_) => PROJECT_DIRS.config_dir().join("config"),
- }
+ env::var("BAT_CONFIG_PATH")
+ .ok()
+ .map(PathBuf::from)
+ .filter(|config_path| config_path.is_file())
+ .unwrap_or(PROJECT_DIRS.config_dir().join("config"))
}
pub fn get_args_from_config_file() -> Result<Vec<OsString>, shell_words::ParseError> {