delete-hook working

This commit is contained in:
mario 2016-06-30 18:38:03 +02:00
parent 8225f1a93e
commit 2144c8c425
1 changed files with 35 additions and 43 deletions

View File

@ -89,51 +89,43 @@ fn main() {
// per usage und wants one (the second one) back.
let mut counter = 0;
let stdin = stdin();
for rline in stdin.lock().lines() {
let mut line = match rline {
Ok(l) => l,
Err(e) => {
error!("{}", e);
return;
}
};
line.insert(0, '[');
line.push(']');
if counter % 2 == 1 {
if let Ok(ttasks) = import(line.as_bytes()) {
for ttask in ttasks {
// Only every second task is needed, the first one is the
// task before the change, and the second one after
// the change. The (maybe modified) second one is
// expected by taskwarrior.
println!("{}", match serde_json::ser::to_string(&ttask) {
Ok(val) => val,
Err(e) => {
error!("{}", e);
return;
}
});
match ttask.status() {
&task_hookrs::status::TaskStatus::Deleted => {
match libimagtodo::delete::delete(rt.store(), *ttask.uuid()) {
Ok(_) => { }
Err(e) => {
trace_error(&e);
error!("{}", e);
return;
}
let mut stdin = stdin.lock();
if let Ok(ttasks) = import_tasks(stdin) {
for ttask in ttasks {
if counter % 2 == 1 {
// Only every second task is needed, the first one is the
// task before the change, and the second one after
// the change. The (maybe modified) second one is
// expected by taskwarrior.
println!("{}", match serde_json::ser::to_string(&ttask) {
Ok(val) => val,
Err(e) => {
error!("{}", e);
return;
}
});
match ttask.status() {
&task_hookrs::status::TaskStatus::Deleted => {
match libimagtodo::delete::delete(rt.store(), *ttask.uuid()) {
Ok(_) => {
println!("Deleted task {}", *ttask.uuid());
}
Err(e) => {
trace_error(&e);
error!("{}", e);
return;
}
}
_ => {
}
} // end match ttask.status()
} // end for
}
else {
error!("No usable input");
}
}
counter += 1;
}
_ => {
}
} // end match ttask.status()
} // end if c % 2
counter += 1;
} // end for
} // end if let
else {
error!("No usable input");
}
}
else {