From 714debc94b0ef2b543949241f1eb04ae5738ad0c Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 25 Oct 2026 13:39:44 +0100 Subject: add force module usable by API and CLI --- src/config/mod.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/config') diff --git a/src/config/mod.rs b/src/config/mod.rs index 0771e7e..c83ca70 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -65,6 +65,9 @@ const fn option( } } +/// What `--force` may override at start (`force`). +pub(crate) const FORCE: &[&str] = &["swarmId"]; + /// Every option. Names are the long option names and the configuration file keys. pub(crate) const OPTIONS: &[OptionSpec] = &[ option( @@ -109,6 +112,13 @@ pub(crate) const OPTIONS: &[OptionSpec] = &[ Some("false"), "Start a new swarm, as its genesis node, instead of joining one through seeds. Every start with it starts another new swarm: drop it once the swarm exists, and give the node seeds instead. Can't be combined with seeds. With a --state-file that remembers a swarm, it starts that swarm again instead (empty; nodes of it still running merge with this one).", ), + option( + "force", + Kind::List, + "NAME,[NAME...]", + None, + "Override checks that otherwise refuse to start: true for all, or names: swarmId (a backup of another swarm than the state file remembers).", + ), option( "recover-from", Kind::Text, @@ -238,6 +248,8 @@ pub(crate) struct Settings { pub(crate) genesis: bool, pub(crate) state_file: Option, pub(crate) recover_from: Option, + #[serde(default)] + pub(crate) force: Vec, pub(crate) swarm_key_file: Option, pub(crate) alias: Option, #[serde(default = "default_keepalive_secs")] @@ -311,6 +323,8 @@ impl Settings { ); } } + crate::force::Force::parse(self.force.iter().map(String::as_str), FORCE) + .map_err(|reason| anyhow!("force: {reason}"))?; // Contradictions, not overrides: an error wherever the options come from. if self.genesis && !self.seeds.is_empty() { bail!( -- cgit v1.3.1