Refactor imag-habit to new store iterator interface
This commit is contained in:
parent
11f9a9027e
commit
519b6f7ef2
1 changed files with 8 additions and 0 deletions
|
@ -57,6 +57,7 @@ use prettytable::row::Row;
|
||||||
use libimagrt::runtime::Runtime;
|
use libimagrt::runtime::Runtime;
|
||||||
use libimagrt::setup::generate_runtime_setup;
|
use libimagrt::setup::generate_runtime_setup;
|
||||||
use libimagerror::trace::{MapErrTrace, trace_error};
|
use libimagerror::trace::{MapErrTrace, trace_error};
|
||||||
|
use libimagerror::iter::TraceIterator;
|
||||||
use libimagerror::exit::ExitUnwrap;
|
use libimagerror::exit::ExitUnwrap;
|
||||||
use libimagerror::io::ToExitCode;
|
use libimagerror::io::ToExitCode;
|
||||||
use libimaghabit::store::HabitStore;
|
use libimaghabit::store::HabitStore;
|
||||||
|
@ -167,6 +168,7 @@ fn delete(rt: &Runtime) {
|
||||||
.store()
|
.store()
|
||||||
.all_habit_templates()
|
.all_habit_templates()
|
||||||
.map_err_trace_exit_unwrap(1)
|
.map_err_trace_exit_unwrap(1)
|
||||||
|
.trace_unwrap_exit(1)
|
||||||
.map(|sid| (sid.clone(), rt.store().get(sid).map_err_trace_exit_unwrap(1))) // get the FileLockEntry
|
.map(|sid| (sid.clone(), rt.store().get(sid).map_err_trace_exit_unwrap(1))) // get the FileLockEntry
|
||||||
.filter(|&(_, ref habit)| match habit { // filter for name of habit == name we look for
|
.filter(|&(_, ref habit)| match habit { // filter for name of habit == name we look for
|
||||||
&Some(ref h) => h.habit_name().map_err_trace_exit_unwrap(1) == name,
|
&Some(ref h) => h.habit_name().map_err_trace_exit_unwrap(1) == name,
|
||||||
|
@ -198,6 +200,7 @@ fn delete(rt: &Runtime) {
|
||||||
fle
|
fle
|
||||||
.linked_instances()
|
.linked_instances()
|
||||||
.map_err_trace_exit_unwrap(1)
|
.map_err_trace_exit_unwrap(1)
|
||||||
|
.trace_unwrap_exit(1)
|
||||||
.filter_map(get_instance)
|
.filter_map(get_instance)
|
||||||
.filter(has_template_name)
|
.filter(has_template_name)
|
||||||
.map(instance_location)
|
.map(instance_location)
|
||||||
|
@ -249,6 +252,7 @@ fn today(rt: &Runtime, future: bool) {
|
||||||
.store()
|
.store()
|
||||||
.all_habit_templates()
|
.all_habit_templates()
|
||||||
.map_err_trace_exit_unwrap(1)
|
.map_err_trace_exit_unwrap(1)
|
||||||
|
.trace_unwrap_exit(1)
|
||||||
.filter_map(|id| match rt.store().get(id.clone()) {
|
.filter_map(|id| match rt.store().get(id.clone()) {
|
||||||
Ok(Some(h)) => Some(h),
|
Ok(Some(h)) => Some(h),
|
||||||
Ok(None) => {
|
Ok(None) => {
|
||||||
|
@ -396,6 +400,7 @@ fn list(rt: &Runtime) {
|
||||||
.store()
|
.store()
|
||||||
.all_habit_templates()
|
.all_habit_templates()
|
||||||
.map_err_trace_exit_unwrap(1)
|
.map_err_trace_exit_unwrap(1)
|
||||||
|
.trace_unwrap_exit(1)
|
||||||
.filter_map(|id| match rt.store().get(id.clone()) {
|
.filter_map(|id| match rt.store().get(id.clone()) {
|
||||||
Ok(Some(h)) => Some(h),
|
Ok(Some(h)) => Some(h),
|
||||||
Ok(None) => {
|
Ok(None) => {
|
||||||
|
@ -451,6 +456,7 @@ fn show(rt: &Runtime) {
|
||||||
.store()
|
.store()
|
||||||
.all_habit_templates()
|
.all_habit_templates()
|
||||||
.map_err_trace_exit_unwrap(1)
|
.map_err_trace_exit_unwrap(1)
|
||||||
|
.trace_unwrap_exit(1)
|
||||||
.filter_map(|id| get_from_store(rt.store(), id))
|
.filter_map(|id| get_from_store(rt.store(), id))
|
||||||
.filter(|h| h.habit_name().map(|n| name == n).map_err_trace_exit_unwrap(1))
|
.filter(|h| h.habit_name().map(|n| name == n).map_err_trace_exit_unwrap(1))
|
||||||
.enumerate()
|
.enumerate()
|
||||||
|
@ -474,6 +480,7 @@ fn show(rt: &Runtime) {
|
||||||
let _ = habit
|
let _ = habit
|
||||||
.linked_instances()
|
.linked_instances()
|
||||||
.map_err_trace_exit_unwrap(1)
|
.map_err_trace_exit_unwrap(1)
|
||||||
|
.trace_unwrap_exit(1)
|
||||||
.filter_map(|instance_id| {
|
.filter_map(|instance_id| {
|
||||||
debug!("Getting: {:?}", instance_id);
|
debug!("Getting: {:?}", instance_id);
|
||||||
rt.store().get(instance_id).map_err_trace_exit_unwrap(1)
|
rt.store().get(instance_id).map_err_trace_exit_unwrap(1)
|
||||||
|
@ -505,6 +512,7 @@ fn done(rt: &Runtime) {
|
||||||
.store()
|
.store()
|
||||||
.all_habit_templates()
|
.all_habit_templates()
|
||||||
.map_err_trace_exit_unwrap(1)
|
.map_err_trace_exit_unwrap(1)
|
||||||
|
.trace_unwrap_exit(1)
|
||||||
.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(1);
|
let due = h.next_instance_date().map_err_trace_exit_unwrap(1);
|
||||||
|
|
Loading…
Reference in a new issue