Adjust generated fields to also have 'key' access
This permits them to also fill in related fields if needed.
This commit is contained in:
parent
77842f1f6d
commit
61eb7cc6d6
|
@ -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<String, Box<dyn Error>>,
|
||||
generator: fn(key: &str, config: &KV, is_dry_run: bool) -> Result<String, Box<dyn Error>>,
|
||||
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),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<String, Box<dyn Error>> {
|
||||
fn make_pad_id(key: &str, config: &crate::KV, is_dry_run: bool) -> Result<String, Box<dyn Error>> {
|
||||
HedgeDoc::new(&config.get("hedgedoc-server-url").unwrap(), is_dry_run).create_pad()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue