From: Ian Jackson Date: Sat, 24 Jul 2021 14:27:56 +0000 (+0100) Subject: config: Break out read_file X-Git-Tag: hippotat/1.0.0~475 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=d7caca4eea7d28e66b0f584582aa57a8f7e7f1fe;p=hippotat.git config: Break out read_file Signed-off-by: Ian Jackson --- diff --git a/src/config.rs b/src/config.rs index da69bf6..7e9e222 100644 --- a/src/config.rs +++ b/src/config.rs @@ -176,6 +176,12 @@ impl Aggregate { if let Some(anyway) = anyway.ok(&y) { return Some(anyway) } y.context("read")?; + self.read_string(s, path)?; + None + } + + #[throws(AE)] // AE does not include path + fn read_string(&mut self, s: String, path_for_loc: &Path) { let mut ini = Ini::new_cs(); ini.set_default_section(OUTSIDE_SECTION); ini.read(s).map_err(|e| anyhow!("{}", e)).context("parse as INI")?; @@ -184,7 +190,7 @@ impl Aggregate { throw!(anyhow!("INI file contains settings outside a section")); } - let loc = Arc::new(path.to_owned()); + let loc = Arc::new(path_for_loc.to_owned()); for (sn, vars) in map { dbg!( InstanceConfig::FIELDS );// check xxx vars are in fields @@ -200,7 +206,7 @@ impl Aggregate { }) ); } - None + } #[throws(AE)] // AE includes path