Shorten code in get_add_tags()

This commit is contained in:
Matthias Beyer 2016-05-19 17:33:28 +02:00
parent 435fd6d7aa
commit 227acd492c

View file

@ -66,13 +66,9 @@ pub fn tag_argument_name() -> &'static str {
///
/// Returns none if the argument was not specified
pub fn get_add_tags(matches: &ArgMatches) -> Option<Vec<Tag>> {
if let Some(v) = extract_tags(matches, tag_subcommand_add_arg_name(), '+') {
return Some(v);
} else {
matches
.values_of(tag_subcommand_add_arg_name())
.map(|values| values.map(String::from).collect())
}
let add = tag_subcommand_add_arg_name();
extract_tags(matches, add, '+')
.or_else(|| matches.values_of(add).map(|values| values.map(String::from).collect()))
}
/// Get the tags which should be removed from the commandline