Add a builder-pattern proj-path setter, for flavor

I like being able to chain methods instead of using a temporary variable
in between, so I've made one single function like I'm doing the builder
pattern.

But not really because there's nothing to build or finalize and such.
This commit is contained in:
2025-07-17 12:13:14 -05:00
parent 626973d2bc
commit 277f638c60

View File

@@ -36,6 +36,18 @@ struct PartialConfig {
token: Option<String>,
}
impl PartialConfig {
// One lonely builder-pattern function to set the project path.
// This is so I can do continuation style calls instead of a bunch of
// successive `let conf = ...` temporaries.
fn project_path(self, path: impl ToString) -> Self{
PartialConfig {
project_path: Some(path.to_string()),
..self
}
}
}
impl TryFrom<&Table> for PartialConfig {
type Error = crate::config::Error;
@@ -82,11 +94,8 @@ fn lconf(text: &str) -> Result<WholeFile> {
for path in per_project_keys {
let tab = get_table(cfg_table, path)?;
let part_cfg = PartialConfig::try_from(tab)?;
let part_cfg = PartialConfig {
project_path: Some(path.clone()),
..part_cfg
};
let part_cfg = PartialConfig::try_from(tab)?
.project_path(path.clone());
whole.project_overrides.push(part_cfg);
}
println!(" ->> lconf - keys {:?}", cfg_table.keys().collect::<Vec<&String>>());