Add header editing support
This commit is contained in:
parent
13af364b76
commit
f627d22057
2 changed files with 22 additions and 8 deletions
|
@ -47,6 +47,7 @@ use std::io::Read;
|
||||||
use libimagerror::trace::MapErrTrace;
|
use libimagerror::trace::MapErrTrace;
|
||||||
use libimagerror::iter::TraceIterator;
|
use libimagerror::iter::TraceIterator;
|
||||||
use libimagentryedit::edit::Edit;
|
use libimagentryedit::edit::Edit;
|
||||||
|
use libimagentryedit::edit::EditHeader;
|
||||||
use libimagrt::setup::generate_runtime_setup;
|
use libimagrt::setup::generate_runtime_setup;
|
||||||
use libimagstore::storeid::IntoStoreId;
|
use libimagstore::storeid::IntoStoreId;
|
||||||
use libimagstore::storeid::StoreIdIterator;
|
use libimagstore::storeid::StoreIdIterator;
|
||||||
|
@ -85,11 +86,8 @@ fn main() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if rt.cli().is_present("edit-header") {
|
let edit_header = rt.cli().is_present("edit-header");
|
||||||
// TODO: support editing of header
|
let edit_header_only = rt.cli().is_present("edit-header-only");
|
||||||
warn!("Editing header is not yet supported by imag-edit");
|
|
||||||
::std::process::exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
StoreIdIterator::new(Box::new(sids.into_iter()))
|
StoreIdIterator::new(Box::new(sids.into_iter()))
|
||||||
.into_get_iter(rt.store())
|
.into_get_iter(rt.store())
|
||||||
|
@ -99,9 +97,19 @@ fn main() {
|
||||||
::std::process::exit(1)
|
::std::process::exit(1)
|
||||||
}))
|
}))
|
||||||
.for_each(|mut entry| {
|
.for_each(|mut entry| {
|
||||||
|
if edit_header {
|
||||||
|
let _ = entry
|
||||||
|
.edit_header_and_content(&rt)
|
||||||
|
.map_err_trace_exit_unwrap(1);
|
||||||
|
} else if edit_header_only {
|
||||||
|
let _ = entry
|
||||||
|
.edit_header(&rt)
|
||||||
|
.map_err_trace_exit_unwrap(1);
|
||||||
|
} else {
|
||||||
let _ = entry
|
let _ = entry
|
||||||
.edit_content(&rt)
|
.edit_content(&rt)
|
||||||
.map_err_trace_exit_unwrap(1);
|
.map_err_trace_exit_unwrap(1);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,5 +47,11 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> {
|
||||||
.multiple(false)
|
.multiple(false)
|
||||||
.help("Also edit the header"))
|
.help("Also edit the header"))
|
||||||
|
|
||||||
|
.arg(Arg::with_name("edit-header-only")
|
||||||
|
.long("header-only")
|
||||||
|
.takes_value(false)
|
||||||
|
.required(false)
|
||||||
|
.multiple(false)
|
||||||
|
.help("Only edit the header"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue