From 61eb7cc6d685cb1bc4d398234cbcdc6359738a9c Mon Sep 17 00:00:00 2001 From: nobody Date: Sat, 17 Aug 2024 03:19:31 +0200 Subject: [PATCH] Adjust generated fields to also have 'key' access This permits them to also fill in related fields if needed. --- src/config_spec.rs | 4 ++-- src/hedgedoc.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/config_spec.rs b/src/config_spec.rs index 38aa73e..4f6b4a3 100644 --- a/src/config_spec.rs +++ b/src/config_spec.rs @@ -95,7 +95,7 @@ pub enum CfgField<'a> { /// Empty by default, can be user-provided, or will be generated randomly. Generated { key: &'a str, - generator: fn(config: &KV, is_dry_run: bool) -> Result>, + generator: fn(key: &str, config: &KV, is_dry_run: bool) -> Result>, generator_description: &'a str, description: &'a str, }, @@ -199,7 +199,7 @@ impl<'a> CfgField<'a> { match self { CfgField::Silent { default, .. } => Ok(Some(default.to_string())), CfgField::Default { default, .. } => Ok(Some(default.to_string())), - CfgField::Generated { generator, .. } => generator(config, is_dry_run()).map(Some), + CfgField::Generated { key, generator, .. } => generator(key, config, is_dry_run()).map(Some), _ => Ok(None), } } diff --git a/src/hedgedoc.rs b/src/hedgedoc.rs index 683c406..1aaceaf 100644 --- a/src/hedgedoc.rs +++ b/src/hedgedoc.rs @@ -96,6 +96,6 @@ impl HedgeDoc { } /// For the config, make a new pad ID (by actually making a pad.) -fn make_pad_id(config: &crate::KV, is_dry_run: bool) -> Result> { +fn make_pad_id(key: &str, config: &crate::KV, is_dry_run: bool) -> Result> { HedgeDoc::new(&config.get("hedgedoc-server-url").unwrap(), is_dry_run).create_pad() }