[Auto] bin/core/contact: Fix Clippy warnings
Signed-off-by: flip1995 <hello@philkrones.com> Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
parent
3963e5ec2d
commit
5b4b699875
4 changed files with 22 additions and 24 deletions
|
@ -56,14 +56,14 @@ use libimagerror::trace::trace_error;
|
||||||
use libimagerror::exit::ExitUnwrap;
|
use libimagerror::exit::ExitUnwrap;
|
||||||
use libimagutil::warn_result::WarnResult;
|
use libimagutil::warn_result::WarnResult;
|
||||||
|
|
||||||
const TEMPLATE : &'static str = include_str!("../static/new-contact-template.toml");
|
const TEMPLATE : &str = include_str!("../static/new-contact-template.toml");
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use toml::Value;
|
use toml::Value;
|
||||||
use super::TEMPLATE;
|
use super::TEMPLATE;
|
||||||
|
|
||||||
const TEMPLATE_WITH_DATA : &'static str = include_str!("../static/new-contact-template-test.toml");
|
const TEMPLATE_WITH_DATA : &str = include_str!("../static/new-contact-template-test.toml");
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_validity_template_toml() {
|
fn test_validity_template_toml() {
|
||||||
|
@ -203,7 +203,7 @@ pub fn create(rt: &Runtime) {
|
||||||
}
|
}
|
||||||
|
|
||||||
let vcard_string = write_component(&vcard);
|
let vcard_string = write_component(&vcard);
|
||||||
let _ = dest
|
dest
|
||||||
.write_all(&vcard_string.as_bytes())
|
.write_all(&vcard_string.as_bytes())
|
||||||
.map_err(Error::from)
|
.map_err(Error::from)
|
||||||
.map_err_trace_exit_unwrap();
|
.map_err_trace_exit_unwrap();
|
||||||
|
@ -219,7 +219,7 @@ pub fn create(rt: &Runtime) {
|
||||||
.create_from_path(&location, &ref_config, &collection_name)
|
.create_from_path(&location, &ref_config, &collection_name)
|
||||||
.map_err_trace_exit_unwrap();
|
.map_err_trace_exit_unwrap();
|
||||||
|
|
||||||
let _ = rt.report_touched(entry.get_location()).unwrap_or_exit();
|
rt.report_touched(entry.get_location()).unwrap_or_exit();
|
||||||
|
|
||||||
info!("Created entry in store");
|
info!("Created entry in store");
|
||||||
} else {
|
} else {
|
||||||
|
@ -578,7 +578,7 @@ mod test_parsing {
|
||||||
use std::io::empty;
|
use std::io::empty;
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
const TEMPLATE : &'static str = include_str!("../static/new-contact-template-test.toml");
|
const TEMPLATE : &str = include_str!("../static/new-contact-template-test.toml");
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_template_names() {
|
fn test_template_names() {
|
||||||
|
|
|
@ -73,14 +73,12 @@ pub fn edit(rt: &Runtime) {
|
||||||
loop {
|
loop {
|
||||||
let res = edit_contact(&rt, &contact, &ref_config, collection_name, force_override);
|
let res = edit_contact(&rt, &contact, &ref_config, collection_name, force_override);
|
||||||
if !retry {
|
if !retry {
|
||||||
let _ = res.map_err_trace_exit_unwrap();
|
res.map_err_trace_exit_unwrap();
|
||||||
} else {
|
} else if ask_continue(&mut input, &mut output) {
|
||||||
if ask_continue(&mut input, &mut output) {
|
continue;
|
||||||
continue;
|
} else {
|
||||||
} else {
|
exit(1)
|
||||||
exit(1)
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,10 +128,10 @@ fn list(rt: &Runtime) {
|
||||||
.map_err_trace_exit_unwrap()
|
.map_err_trace_exit_unwrap()
|
||||||
.into_get_iter()
|
.into_get_iter()
|
||||||
.trace_unwrap_exit()
|
.trace_unwrap_exit()
|
||||||
.map(|fle| fle.ok_or_else(|| Error::from(err_msg("StoreId not found".to_owned()))))
|
.map(|fle| fle.ok_or_else(|| err_msg("StoreId not found".to_owned())))
|
||||||
.trace_unwrap_exit()
|
.trace_unwrap_exit()
|
||||||
.map(|fle| {
|
.map(|fle| {
|
||||||
let _ = rt.report_touched(fle.get_location()).unwrap_or_exit();
|
rt.report_touched(fle.get_location()).unwrap_or_exit();
|
||||||
fle
|
fle
|
||||||
})
|
})
|
||||||
.map(|e| e.deser())
|
.map(|e| e.deser())
|
||||||
|
@ -191,7 +191,7 @@ fn import(rt: &Runtime) {
|
||||||
.retrieve_from_path(&path, &ref_config, &collection_name, force_override)
|
.retrieve_from_path(&path, &ref_config, &collection_name, force_override)
|
||||||
.map_err_trace_exit_unwrap();
|
.map_err_trace_exit_unwrap();
|
||||||
|
|
||||||
let _ = rt.report_touched(entry.get_location()).unwrap_or_exit();
|
rt.report_touched(entry.get_location()).unwrap_or_exit();
|
||||||
} else if path.is_dir() {
|
} else if path.is_dir() {
|
||||||
for entry in WalkDir::new(path).min_depth(1).into_iter() {
|
for entry in WalkDir::new(path).min_depth(1).into_iter() {
|
||||||
let entry = entry
|
let entry = entry
|
||||||
|
@ -205,7 +205,7 @@ fn import(rt: &Runtime) {
|
||||||
.retrieve_from_path(&pb, &ref_config, &collection_name, force_override)
|
.retrieve_from_path(&pb, &ref_config, &collection_name, force_override)
|
||||||
.map_err_trace_exit_unwrap();
|
.map_err_trace_exit_unwrap();
|
||||||
|
|
||||||
let _ = rt.report_touched(fle.get_location()).unwrap_or_exit();
|
rt.report_touched(fle.get_location()).unwrap_or_exit();
|
||||||
info!("Imported: {}", entry.path().to_str().unwrap_or("<non UTF-8 path>"));
|
info!("Imported: {}", entry.path().to_str().unwrap_or("<non UTF-8 path>"));
|
||||||
} else {
|
} else {
|
||||||
warn!("Ignoring non-file: {}", entry.path().to_str().unwrap_or("<non UTF-8 path>"));
|
warn!("Ignoring non-file: {}", entry.path().to_str().unwrap_or("<non UTF-8 path>"));
|
||||||
|
@ -234,7 +234,7 @@ fn show(rt: &Runtime) {
|
||||||
.render("format", &data)
|
.render("format", &data)
|
||||||
.map_err(Error::from)
|
.map_err(Error::from)
|
||||||
.map_err_trace_exit_unwrap();
|
.map_err_trace_exit_unwrap();
|
||||||
let _ = writeln!(outlock, "{}", s).to_exit_code().unwrap_or_exit();
|
writeln!(outlock, "{}", s).to_exit_code().unwrap_or_exit();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,7 +275,7 @@ fn find(rt: &Runtime) {
|
||||||
|| card.fullname().iter().any(|a| str_contains_any(a, &grepstring));
|
|| card.fullname().iter().any(|a| str_contains_any(a, &grepstring));
|
||||||
|
|
||||||
if take {
|
if take {
|
||||||
let _ = rt.report_touched(entry.get_location()).unwrap_or_exit();
|
rt.report_touched(entry.get_location()).unwrap_or_exit();
|
||||||
|
|
||||||
// optimization so we don't have to parse again in the next step
|
// optimization so we don't have to parse again in the next step
|
||||||
Some((entry, card))
|
Some((entry, card))
|
||||||
|
@ -326,7 +326,7 @@ fn find(rt: &Runtime) {
|
||||||
.map_err(Error::from)
|
.map_err(Error::from)
|
||||||
.map_err_trace_exit_unwrap();
|
.map_err_trace_exit_unwrap();
|
||||||
|
|
||||||
let _ = writeln!(rt.stdout(), "{}", s)
|
writeln!(rt.stdout(), "{}", s)
|
||||||
.to_exit_code()
|
.to_exit_code()
|
||||||
.unwrap_or_exit();
|
.unwrap_or_exit();
|
||||||
});
|
});
|
||||||
|
@ -342,17 +342,17 @@ fn get_contact_print_format(config_value_path: &'static str, rt: &Runtime, scmd:
|
||||||
.map(String::from)
|
.map(String::from)
|
||||||
.unwrap_or_else(|| {
|
.unwrap_or_else(|| {
|
||||||
rt.config()
|
rt.config()
|
||||||
.ok_or_else(|| Error::from(err_msg("No configuration file")))
|
.ok_or_else(|| err_msg("No configuration file"))
|
||||||
.map_err_trace_exit_unwrap()
|
.map_err_trace_exit_unwrap()
|
||||||
.read_string(config_value_path)
|
.read_string(config_value_path)
|
||||||
.map_err(Error::from)
|
.map_err(Error::from)
|
||||||
.map_err_trace_exit_unwrap()
|
.map_err_trace_exit_unwrap()
|
||||||
.ok_or_else(|| Error::from(err_msg("Configuration 'contact.list_format' does not exist")))
|
.ok_or_else(|| err_msg("Configuration 'contact.list_format' does not exist"))
|
||||||
.map_err_trace_exit_unwrap()
|
.map_err_trace_exit_unwrap()
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut hb = Handlebars::new();
|
let mut hb = Handlebars::new();
|
||||||
let _ = hb
|
hb
|
||||||
.register_template_string("format", fmt)
|
.register_template_string("format", fmt)
|
||||||
.map_err(Error::from)
|
.map_err(Error::from)
|
||||||
.map_err_trace_exit_unwrap();
|
.map_err_trace_exit_unwrap();
|
||||||
|
|
|
@ -107,7 +107,7 @@ pub fn find_contact_by_hash<'a, H: AsRef<str>>(rt: &'a Runtime, hash: H)
|
||||||
.unwrap() // exited above
|
.unwrap() // exited above
|
||||||
.starts_with(hash.as_ref())
|
.starts_with(hash.as_ref())
|
||||||
{
|
{
|
||||||
let _ = rt.report_touched(entry.get_location()).unwrap_or_exit();
|
rt.report_touched(entry.get_location()).unwrap_or_exit();
|
||||||
Some(entry)
|
Some(entry)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|
Loading…
Reference in a new issue