Beautify get_tags() helper
This commit is contained in:
parent
a005d4209b
commit
55f740497b
1 changed files with 18 additions and 14 deletions
|
@ -153,21 +153,25 @@ fn get_filtered_files_from_backend<'a>(module: &'a Module,
|
|||
}
|
||||
|
||||
fn get_tags<'a>(rt: &Runtime, sub: &ArgMatches<'a, 'a>) -> Vec<String> {
|
||||
debug!("Fetching tags from commandline");
|
||||
sub.value_of("tags").and_then(|tags|
|
||||
Some(tags.split(",")
|
||||
.into_iter()
|
||||
.map(|s| s.to_string())
|
||||
.filter(|e|
|
||||
if e.contains(" ") {
|
||||
warn!("Tag contains spaces: '{}'", e);
|
||||
false
|
||||
} else {
|
||||
true
|
||||
}).collect()
|
||||
)
|
||||
).or(Some(vec![])).unwrap()
|
||||
|
||||
fn reject_if_with_spaces(e: &String) -> bool {
|
||||
if e.contains(" ") {
|
||||
warn!("Tag contains spaces: '{}'", e);
|
||||
false
|
||||
} else {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
debug!("Fetching tags from commandline");
|
||||
sub.value_of("tags").and_then(|tags| {
|
||||
Some(tags.split(",")
|
||||
.into_iter()
|
||||
.map(|s| s.to_string())
|
||||
.filter(|e| reject_if_with_spaces(e))
|
||||
.collect()
|
||||
)
|
||||
}).or(Some(vec![])).unwrap()
|
||||
}
|
||||
|
||||
fn get_matcher<'a>(rt: &Runtime, sub: &ArgMatches<'a, 'a>) -> Option<Regex> {
|
||||
|
|
Loading…
Reference in a new issue