Implement Store::update() interface
This commit is contained in:
parent
9c0796d7b3
commit
1fb29a11c8
1 changed files with 24 additions and 0 deletions
|
@ -1,5 +1,29 @@
|
|||
use std::path::PathBuf;
|
||||
use std::ops::DerefMut;
|
||||
|
||||
use libimagrt::runtime::Runtime;
|
||||
use util::build_toml_header;
|
||||
use util::build_entry_path;
|
||||
|
||||
pub fn update(rt: &Runtime) {
|
||||
rt.cli()
|
||||
.subcommand_matches("update")
|
||||
.map(|scmd| {
|
||||
rt.store()
|
||||
.retrieve(scmd.value_of("id").map(|id| build_entry_path(rt, id)).unwrap())
|
||||
.map(|mut locked_e| {
|
||||
let mut e = locked_e.deref_mut();
|
||||
|
||||
scmd.value_of("content")
|
||||
.map(|new_content| {
|
||||
*e.get_content_mut() = String::from(new_content);
|
||||
debug!("New content set");
|
||||
});
|
||||
|
||||
*e.get_header_mut() = build_toml_header(scmd, e.get_header().clone());
|
||||
debug!("New header set");
|
||||
})
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue