From 7cf246eb73af9c7f33ab90a1185c61a35cd02a58 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Mon, 22 Sep 2025 20:29:19 +0000 Subject: [PATCH] Support dot paths for -O/--option command-line args. (fixes #162) (fixes #167) Signed-off-by: Jason Volk --- src/main/clap.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/clap.rs b/src/main/clap.rs index 01602e24..bee5cde2 100644 --- a/src/main/clap.rs +++ b/src/main/clap.rs @@ -179,11 +179,11 @@ pub(crate) fn update(mut config: Figment, args: &Args) -> Result { // All other individual overrides can go last in case we have options which // set multiple conf items at once and the user still needs granular overrides. for option in &args.option { - let (key, val) = option + let (path, val) = option .split_once('=') .ok_or_else(|| err!("Missing '=' in -O/--option: {option:?}"))?; - if key.is_empty() { + if path.is_empty() { return Err!("Missing key= in -O/--option: {option:?}"); } @@ -193,12 +193,9 @@ pub(crate) fn update(mut config: Figment, args: &Args) -> Result { // The value has to pass for what would appear as a line in the TOML file. let val = toml::from_str::(option)?; - let FigmentValue::Dict(_, val) = val else { - panic!("Unexpected Figment Value: {val:#?}"); - }; // Figment::merge() overrides existing - config = config.merge((key, val[key].clone())); + config = config.merge((path, val.find(path))); } Ok(config)