diff --git a/bin/core/imag-edit/src/main.rs b/bin/core/imag-edit/src/main.rs index da84abb2..4b6387d9 100644 --- a/bin/core/imag-edit/src/main.rs +++ b/bin/core/imag-edit/src/main.rs @@ -47,6 +47,7 @@ use std::io::Read; use libimagerror::trace::MapErrTrace; use libimagerror::iter::TraceIterator; use libimagentryedit::edit::Edit; +use libimagentryedit::edit::EditHeader; use libimagrt::setup::generate_runtime_setup; use libimagstore::storeid::IntoStoreId; use libimagstore::storeid::StoreIdIterator; @@ -85,11 +86,8 @@ fn main() { } }; - if rt.cli().is_present("edit-header") { - // TODO: support editing of header - warn!("Editing header is not yet supported by imag-edit"); - ::std::process::exit(1); - } + let edit_header = rt.cli().is_present("edit-header"); + let edit_header_only = rt.cli().is_present("edit-header-only"); StoreIdIterator::new(Box::new(sids.into_iter())) .into_get_iter(rt.store()) @@ -99,9 +97,19 @@ fn main() { ::std::process::exit(1) })) .for_each(|mut entry| { - let _ = entry - .edit_content(&rt) - .map_err_trace_exit_unwrap(1); + 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 + .edit_content(&rt) + .map_err_trace_exit_unwrap(1); + } }); } diff --git a/bin/core/imag-edit/src/ui.rs b/bin/core/imag-edit/src/ui.rs index dbf0b85b..2f3e8f66 100644 --- a/bin/core/imag-edit/src/ui.rs +++ b/bin/core/imag-edit/src/ui.rs @@ -47,5 +47,11 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { .multiple(false) .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")) }