[Auto] bin/core/habit: Fix Clippy warnings
Signed-off-by: flip1995 <hello@philkrones.com> Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
parent
171757f5ca
commit
c9c7439f92
1 changed files with 23 additions and 25 deletions
|
@ -83,7 +83,7 @@ fn main() {
|
||||||
ui::build_ui);
|
ui::build_ui);
|
||||||
|
|
||||||
|
|
||||||
let _ = rt
|
rt
|
||||||
.cli()
|
.cli()
|
||||||
.subcommand_name()
|
.subcommand_name()
|
||||||
.map(|name| {
|
.map(|name| {
|
||||||
|
@ -155,7 +155,7 @@ fn create(rt: &Runtime) {
|
||||||
debug!("Builder = {:?}", hb);
|
debug!("Builder = {:?}", hb);
|
||||||
|
|
||||||
let fle = hb.build(rt.store()).map_err_trace_exit_unwrap();
|
let fle = hb.build(rt.store()).map_err_trace_exit_unwrap();
|
||||||
let _ = rt.report_touched(fle.get_location()).unwrap_or_exit();
|
rt.report_touched(fle.get_location()).unwrap_or_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn delete(rt: &Runtime) {
|
fn delete(rt: &Runtime) {
|
||||||
|
@ -201,10 +201,10 @@ fn delete(rt: &Runtime) {
|
||||||
if ask_bool(&q, Some(false), &mut input, &mut output)
|
if ask_bool(&q, Some(false), &mut input, &mut output)
|
||||||
.map_err_trace_exit_unwrap()
|
.map_err_trace_exit_unwrap()
|
||||||
{
|
{
|
||||||
let _ = do_delete(id);
|
do_delete(id);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let _ = do_delete(id);
|
do_delete(id);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -227,10 +227,10 @@ fn delete(rt: &Runtime) {
|
||||||
if ask_bool(&q, Some(false), &mut input, &mut output)
|
if ask_bool(&q, Some(false), &mut input, &mut output)
|
||||||
.map_err_trace_exit_unwrap()
|
.map_err_trace_exit_unwrap()
|
||||||
{
|
{
|
||||||
let _ = do_delete_template(sid);
|
do_delete_template(sid);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let _ = do_delete_template(sid);
|
do_delete_template(sid);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
@ -253,12 +253,10 @@ fn today(rt: &Runtime, future: bool) {
|
||||||
let futu = scmd.is_present("today-show-future");
|
let futu = scmd.is_present("today-show-future");
|
||||||
let done = scmd.is_present("today-done");
|
let done = scmd.is_present("today-done");
|
||||||
(futu, done)
|
(futu, done)
|
||||||
|
} else if let Some(status) = rt.cli().subcommand_matches("status") {
|
||||||
|
(true, status.is_present("status-done"))
|
||||||
} else {
|
} else {
|
||||||
if let Some(status) = rt.cli().subcommand_matches("status") {
|
(true, false)
|
||||||
(true, status.is_present("status-done"))
|
|
||||||
} else {
|
|
||||||
(true, false)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let today = ::chrono::offset::Local::today().naive_local();
|
let today = ::chrono::offset::Local::today().naive_local();
|
||||||
|
@ -329,7 +327,7 @@ fn today(rt: &Runtime, future: bool) {
|
||||||
|
|
||||||
if let Some(date) = date {
|
if let Some(date) = date {
|
||||||
let is_done = element
|
let is_done = element
|
||||||
.instance_exists_for_date(&date)
|
.instance_exists_for_date(date)
|
||||||
.map_err_trace_exit_unwrap();
|
.map_err_trace_exit_unwrap();
|
||||||
|
|
||||||
if show_done || !is_done {
|
if show_done || !is_done {
|
||||||
|
@ -370,7 +368,7 @@ fn today(rt: &Runtime, future: bool) {
|
||||||
.map_err_trace_exit_unwrap()
|
.map_err_trace_exit_unwrap()
|
||||||
.map(|date| {
|
.map(|date| {
|
||||||
let instance_exists = habit
|
let instance_exists = habit
|
||||||
.instance_exists_for_date(&date)
|
.instance_exists_for_date(date)
|
||||||
.map_err_trace_exit_unwrap();
|
.map_err_trace_exit_unwrap();
|
||||||
|
|
||||||
debug!("instance exists for {:?} for {:?} = {:?}",
|
debug!("instance exists for {:?} for {:?} = {:?}",
|
||||||
|
@ -390,7 +388,7 @@ fn today(rt: &Runtime, future: bool) {
|
||||||
let mut list = lister_fn(&e);
|
let mut list = lister_fn(&e);
|
||||||
|
|
||||||
{
|
{
|
||||||
let _ = rt
|
rt
|
||||||
.report_touched(e.get_location())
|
.report_touched(e.get_location())
|
||||||
.unwrap_or_exit();
|
.unwrap_or_exit();
|
||||||
}
|
}
|
||||||
|
@ -414,7 +412,7 @@ fn list(rt: &Runtime) {
|
||||||
let recur = h.habit_recur_spec().map_err_trace_exit_unwrap();
|
let recur = h.habit_recur_spec().map_err_trace_exit_unwrap();
|
||||||
let comm = h.habit_comment().map_err_trace_exit_unwrap();
|
let comm = h.habit_comment().map_err_trace_exit_unwrap();
|
||||||
let (due, done) = if let Some(date) = h.next_instance_date().map_err_trace_exit_unwrap() {
|
let (due, done) = if let Some(date) = h.next_instance_date().map_err_trace_exit_unwrap() {
|
||||||
let done = h.instance_exists_for_date(&date)
|
let done = h.instance_exists_for_date(date)
|
||||||
.map(|b| if b { "x" } else { "" })
|
.map(|b| if b { "x" } else { "" })
|
||||||
.map(String::from)
|
.map(String::from)
|
||||||
.map_err_trace_exit_unwrap();
|
.map_err_trace_exit_unwrap();
|
||||||
|
@ -438,7 +436,7 @@ fn list(rt: &Runtime) {
|
||||||
let mut table = Table::new();
|
let mut table = Table::new();
|
||||||
table.set_titles(Row::new(header));
|
table.set_titles(Row::new(header));
|
||||||
|
|
||||||
let _ = rt
|
rt
|
||||||
.store()
|
.store()
|
||||||
.all_habit_templates()
|
.all_habit_templates()
|
||||||
.map_err_trace_exit_unwrap()
|
.map_err_trace_exit_unwrap()
|
||||||
|
@ -460,7 +458,7 @@ fn list(rt: &Runtime) {
|
||||||
let mut list = lister_fn(&e);
|
let mut list = lister_fn(&e);
|
||||||
|
|
||||||
{
|
{
|
||||||
let _ = rt.report_touched(e.get_location()).unwrap_or_exit();
|
rt.report_touched(e.get_location()).unwrap_or_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
v.append(&mut list);
|
v.append(&mut list);
|
||||||
|
@ -484,7 +482,7 @@ fn show(rt: &Runtime) {
|
||||||
use libimagutil::date::date_to_string;
|
use libimagutil::date::date_to_string;
|
||||||
use libimaghabit::instance::HabitInstance;
|
use libimaghabit::instance::HabitInstance;
|
||||||
|
|
||||||
let date = date_to_string(&i.get_date().map_err_trace_exit_unwrap());
|
let date = date_to_string(i.get_date().map_err_trace_exit_unwrap());
|
||||||
let comm = i.get_comment(rt.store()).map_err_trace_exit_unwrap();
|
let comm = i.get_comment(rt.store()).map_err_trace_exit_unwrap();
|
||||||
|
|
||||||
vec![date, comm]
|
vec![date, comm]
|
||||||
|
@ -512,7 +510,7 @@ fn show(rt: &Runtime) {
|
||||||
let recur = habit.habit_recur_spec().map_err_trace_exit_unwrap();
|
let recur = habit.habit_recur_spec().map_err_trace_exit_unwrap();
|
||||||
let comm = habit.habit_comment().map_err_trace_exit_unwrap();
|
let comm = habit.habit_comment().map_err_trace_exit_unwrap();
|
||||||
|
|
||||||
let _ = writeln!(rt.stdout(),
|
writeln!(rt.stdout(),
|
||||||
"{i} - {name}\nBase : {b},\nRecurrence: {r}\nComment : {c}\n",
|
"{i} - {name}\nBase : {b},\nRecurrence: {r}\nComment : {c}\n",
|
||||||
i = i,
|
i = i,
|
||||||
name = name,
|
name = name,
|
||||||
|
@ -544,7 +542,7 @@ fn show(rt: &Runtime) {
|
||||||
let mut instances = instance_lister_fn(&rt, &e);
|
let mut instances = instance_lister_fn(&rt, &e);
|
||||||
|
|
||||||
{
|
{
|
||||||
let _ = rt.report_touched(e.get_location()).unwrap_or_exit();
|
rt.report_touched(e.get_location()).unwrap_or_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
v.append(&mut instances);
|
v.append(&mut instances);
|
||||||
|
@ -574,7 +572,7 @@ fn done(rt: &Runtime) {
|
||||||
.filter_map(|id| get_from_store(rt.store(), id))
|
.filter_map(|id| get_from_store(rt.store(), id))
|
||||||
.filter(|h| {
|
.filter(|h| {
|
||||||
let due = h.next_instance_date().map_err_trace_exit_unwrap();
|
let due = h.next_instance_date().map_err_trace_exit_unwrap();
|
||||||
due.map(|d| (d == today || d < today) || scmd.is_present("allow-future"))
|
due.map(|d| d <= today || scmd.is_present("allow-future"))
|
||||||
.unwrap_or(false)
|
.unwrap_or(false)
|
||||||
})
|
})
|
||||||
.filter(|h| {
|
.filter(|h| {
|
||||||
|
@ -592,11 +590,11 @@ fn done(rt: &Runtime) {
|
||||||
let next_instance_date = r.next_instance_date().map_err_trace_exit_unwrap();
|
let next_instance_date = r.next_instance_date().map_err_trace_exit_unwrap();
|
||||||
if let Some(next) = next_instance_date {
|
if let Some(next) = next_instance_date {
|
||||||
debug!("Creating new instance on {:?}", next);
|
debug!("Creating new instance on {:?}", next);
|
||||||
r.create_instance_with_date(rt.store(), &next)
|
r.create_instance_with_date(rt.store(), next)
|
||||||
.map_err_trace_exit_unwrap();
|
.map_err_trace_exit_unwrap();
|
||||||
|
|
||||||
info!("Done on {date}: {name}",
|
info!("Done on {date}: {name}",
|
||||||
date = libimagutil::date::date_to_string(&next),
|
date = libimagutil::date::date_to_string(next),
|
||||||
name = next_instance_name);
|
name = next_instance_name);
|
||||||
} else {
|
} else {
|
||||||
info!("Ignoring: {}, because there is no due date (the habit is finised)",
|
info!("Ignoring: {}, because there is no due date (the habit is finised)",
|
||||||
|
@ -604,7 +602,7 @@ fn done(rt: &Runtime) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
let _ = rt.report_touched(r.get_location()).unwrap_or_exit();
|
rt.report_touched(r.get_location()).unwrap_or_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -627,6 +625,6 @@ fn get_from_store<'a>(store: &'a Store, id: StoreId) -> Option<FileLockEntry<'a>
|
||||||
}
|
}
|
||||||
|
|
||||||
fn date_to_string_helper(d: chrono::NaiveDate) -> String {
|
fn date_to_string_helper(d: chrono::NaiveDate) -> String {
|
||||||
libimagutil::date::date_to_string(&d)
|
libimagutil::date::date_to_string(d)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue