toml-config: add named actions
This commit is contained in:
parent
8552c5f1eb
commit
3100773ae0
15 changed files with 587 additions and 4 deletions
|
|
@ -159,6 +159,8 @@ fn create_string_spec(description: &str, spec: &StringSpec) -> Value {
|
|||
if let Some(values) = &spec.values {
|
||||
let strings: Vec<_> = values.iter().map(|v| &v.value.value).collect();
|
||||
res.insert("enum".into(), json!(strings));
|
||||
} else if let Some(pattern) = &spec.pattern {
|
||||
res.insert("pattern".into(), json!(pattern));
|
||||
}
|
||||
res.into()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -230,6 +230,12 @@ fn write_string_spec(buf: &mut Vec<u8>, spec: &StringSpec, pad: &str) -> Result<
|
|||
writeln!(buf)?;
|
||||
}
|
||||
writeln!(buf)?;
|
||||
} else if let Some(pattern) = &spec.pattern {
|
||||
writeln!(
|
||||
buf,
|
||||
"{pad}The string should match the following regular expression: `{pattern}`"
|
||||
)?;
|
||||
writeln!(buf)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ pub enum RefOrSpec<T> {
|
|||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct StringSpec {
|
||||
pub pattern: Option<String>,
|
||||
pub values: Option<Vec<Described<StringSpecValue>>>,
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue