Rewrite UI with Task::import()
This commit is contained in:
parent
0041a648c3
commit
b918f4abbe
1 changed files with 5 additions and 28 deletions
|
@ -47,37 +47,14 @@ fn tw_hook(rt: &Runtime) {
|
||||||
if subcmd.is_present("add") {
|
if subcmd.is_present("add") {
|
||||||
let stdin = stdin();
|
let stdin = stdin();
|
||||||
let mut stdin = stdin.lock();
|
let mut stdin = stdin.lock();
|
||||||
let mut line = String::new();
|
|
||||||
|
|
||||||
if let Err(e) = stdin.read_line(&mut line) {
|
match Task::import(rt.store(), stdin) {
|
||||||
trace_error(&e);
|
Ok((_, uuid)) => info!("Task {} stored in imag", uuid),
|
||||||
exit(1);
|
|
||||||
};
|
|
||||||
|
|
||||||
if let Ok(ttask) = import_task(&line.as_str()) {
|
|
||||||
match serde_json::ser::to_string(&ttask) {
|
|
||||||
Ok(val) => println!("{}", val),
|
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
trace_error(&e);
|
trace_error(&e);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let uuid = *ttask.uuid();
|
|
||||||
match ttask.into_task(rt.store()) {
|
|
||||||
Ok(val) => {
|
|
||||||
println!("Task {} stored in imag", uuid);
|
|
||||||
val
|
|
||||||
},
|
|
||||||
Err(e) => {
|
|
||||||
trace_error(&e);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
error!("No usable input");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
} else if subcmd.is_present("delete") {
|
} else if subcmd.is_present("delete") {
|
||||||
// The used hook is "on-modify". This hook gives two json-objects
|
// The used hook is "on-modify". This hook gives two json-objects
|
||||||
// per usage und wants one (the second one) back.
|
// per usage und wants one (the second one) back.
|
||||||
|
|
Loading…
Reference in a new issue