diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2016-03-25 16:38:17 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2016-03-26 16:43:33 +0100 |
commit | 272243a125bc92d81072f6535c4ab0702e0cf1df (patch) | |
tree | 208186986e6d3ab24929bfc258291580498f3cb8 /imag-notes | |
parent | ded011b5b64621ee69b54dfc1d85d7d18b3befed (diff) |
Implement edit()
Diffstat (limited to 'imag-notes')
-rw-r--r-- | imag-notes/src/main.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/imag-notes/src/main.rs b/imag-notes/src/main.rs index c49a4716..0e5fa67b 100644 --- a/imag-notes/src/main.rs +++ b/imag-notes/src/main.rs @@ -10,6 +10,7 @@ extern crate libimagutil; use std::process::exit; +use libimagrt::edit::Edit; use libimagrt::runtime::Runtime; use libimagnotes::note::Note; use libimagutil::trace::trace_error; @@ -73,8 +74,19 @@ fn delete(rt: &Runtime) { .ok(); } -fn edit(_: &Runtime) { - unimplemented!() +fn edit(rt: &Runtime) { + let note = Note::retrieve(rt.store(), name_from_cli(rt, "edit")); + if note.is_err() { + trace_error(¬e.err().unwrap()); + warn!("Cannot edit nonexistent Note"); + } else { + let mut note = note.unwrap(); + if let Err(e) = note.edit_content(rt) { + trace_error(&e); + warn!("Editing failed"); + } + } + } fn list(rt: &Runtime) { |