From f10ee79ddc2b0a541f1011aa395990df21e456b5 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 29 Nov 2026 01:12:18 +0000 Subject: config: files, arguments and layers, by a program's own options What reads a configuration moves to the crate config, as it was, so that other programs read theirs alike: * option: Kind, OptionSpec, and Schema: a program's options, those that can't be combined, and those that are gone; * file: TOML and JSON files, their includes and unsets; * arguments: the options as arguments, --config and --unset, and files and arguments put together (merged); * layer: values and where they came from, a later source over the earlier ones (overlay), what a value was made of (Sources); * units: durations and sizes as operators write them, which continuum keeps under crate::units. Each takes the schema it reads by, where continuum's code went by its own tables: the node's is config::SCHEMA, a party's client's config::PARTY. Whether a value is shown goes by the schema read by, so an option of the node is no secret for being one of the client's. continuum keeps its options, the settings they make, their checks and the report; its tests of files and layers stay, by the node's options, and the crate has one by a schema of its own. --- src/federation/party.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/federation/party.rs') diff --git a/src/federation/party.rs b/src/federation/party.rs index 4420478..eaf28b5 100644 --- a/src/federation/party.rs +++ b/src/federation/party.rs @@ -651,7 +651,7 @@ pub(crate) async fn main() -> Result<()> { .map(|dir| dir.join("party.toml")) .filter(|file| file.exists()) .collect(); - let (merged, _) = config::merged_with(&matches, config::PARTY_OPTIONS, &first)?; + let (merged, _) = config::merged(&matches, &config::PARTY, &first)?; let mut options: Options = config::read(&merged)?; // In a federation's directory, its record and key, where none other is named. if let Some(dir) = &dir { @@ -3320,7 +3320,7 @@ mod tests { "proposals", ]) .unwrap(); - let (merged, _) = config::merged(&matches, config::PARTY_OPTIONS).unwrap(); + let (merged, _) = config::merged(&matches, &config::PARTY, &[]).unwrap(); let options: super::Options = config::read(&merged).unwrap(); assert_eq!(options.node, "http://tv:secret@localhost:3001"); assert_eq!(options.key.as_deref(), Some("laptop.key")); @@ -3328,6 +3328,6 @@ mod tests { assert_eq!(options.token, None); // A key naming none of the client's options is an error, as in the node's files. std::fs::write(&file, "bind-addr = \"127.0.0.1:3000\"\n").unwrap(); - assert!(config::merged(&matches, config::PARTY_OPTIONS).is_err()); + assert!(config::merged(&matches, &config::PARTY, &[]).is_err()); } } -- cgit v1.3.1