Add setting to override basepath setting

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
Matthias Beyer 2019-04-22 12:58:12 +02:00
parent 427eac76fe
commit 9424661393
2 changed files with 28 additions and 15 deletions

View file

@ -87,6 +87,7 @@ fn main() {
fn deref(rt: &Runtime) { fn deref(rt: &Runtime) {
let cmd = rt.cli().subcommand_matches("deref").unwrap(); let cmd = rt.cli().subcommand_matches("deref").unwrap();
let basepath = cmd.value_of("override-basepath");
let ids = rt.ids::<::ui::PathProvider>().map_err_trace_exit_unwrap(); let ids = rt.ids::<::ui::PathProvider>().map_err_trace_exit_unwrap();
let cfg = get_ref_config(&rt, "imag-ref").map_err_trace_exit_unwrap(); let cfg = get_ref_config(&rt, "imag-ref").map_err_trace_exit_unwrap();
let out = rt.stdout(); let out = rt.stdout();
@ -96,9 +97,13 @@ fn deref(rt: &Runtime) {
.for_each(|id| { .for_each(|id| {
match rt.store().get(id.clone()).map_err_trace_exit_unwrap() { match rt.store().get(id.clone()).map_err_trace_exit_unwrap() {
Some(entry) => { Some(entry) => {
entry let r_entry = entry.as_ref_with_hasher::<DefaultHasher>();
.as_ref_with_hasher::<DefaultHasher>()
.get_path(&cfg) if let Some(alternative_basepath) = basepath {
r_entry.get_path_with_basepath_setting(&cfg, alternative_basepath)
} else {
r_entry.get_path(&cfg)
}
.map_err_trace_exit_unwrap() .map_err_trace_exit_unwrap()
.to_str() .to_str()
.ok_or_else(|| { .ok_or_else(|| {

View file

@ -45,6 +45,14 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> {
.required(false) .required(false)
.multiple(false) .multiple(false)
.help("Ignore store entries which are not refs and do not print error message")) .help("Ignore store entries which are not refs and do not print error message"))
.arg(Arg::with_name("override-basepath")
.long("basepath-setting")
.short("B")
.takes_value(true)
.required(false)
.multiple(false)
.help("Override the basepath key to look up in the configuration"))
) )
.subcommand(SubCommand::with_name("remove") .subcommand(SubCommand::with_name("remove")