1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-09-03 03:42:26 +01:00

Applied linter fixes

This commit is contained in:
Daniele Esposti
2019-03-08 10:46:49 +00:00
committed by David Peter
parent a21ae614e6
commit 82f14121bd
12 changed files with 37 additions and 44 deletions

View File

@@ -13,7 +13,7 @@ pub fn config_file() -> PathBuf {
.ok()
.map(PathBuf::from)
.filter(|config_path| config_path.is_file())
.unwrap_or(PROJECT_DIRS.config_dir().join("config"))
.unwrap_or_else(|| PROJECT_DIRS.config_dir().join("config"))
}
pub fn get_args_from_config_file() -> Result<Vec<OsString>, shell_words::ParseError> {
@@ -22,19 +22,19 @@ pub fn get_args_from_config_file() -> Result<Vec<OsString>, shell_words::ParseEr
.ok()
.map(|content| get_args_from_str(&content)),
)?
.unwrap_or(vec![]))
.unwrap_or_else(|| vec![]))
}
pub fn get_args_from_env_var() -> Option<Result<Vec<OsString>, shell_words::ParseError>> {
env::var("BAT_OPTS").ok().map(|s| get_args_from_str(&s))
}
fn get_args_from_str<'a>(content: &'a str) -> Result<Vec<OsString>, shell_words::ParseError> {
fn get_args_from_str(content: &str) -> Result<Vec<OsString>, shell_words::ParseError> {
let args_per_line = content
.split('\n')
.map(|line| line.trim())
.filter(|line| !line.is_empty())
.filter(|line| !line.starts_with("#"))
.filter(|line| !line.starts_with('#'))
.map(|line| shell_words::split(line))
.collect::<Result<Vec<_>, _>>()?;