diff --git a/crates/weaver_forge/src/config.rs b/crates/weaver_forge/src/config.rs index cbe61583..c165def0 100644 --- a/crates/weaver_forge/src/config.rs +++ b/crates/weaver_forge/src/config.rs @@ -81,7 +81,7 @@ pub(crate) struct TargetConfig { /// Parameters for the templates. /// These parameters can be overridden by parameters passed to the CLI. - #[serde(default)] + #[serde(default = "default_templates")] pub(crate) params: HashMap, /// Configuration for the templates. @@ -94,6 +94,113 @@ pub(crate) struct TargetConfig { pub(crate) acronyms: Vec, } +fn default_templates() -> Vec { + vec![ + TemplateConfig { + pattern: Glob::new("**/registry.md").expect("Invalid pattern"), + filter: Filter::try_new(".").expect("Invalid filter"), + r#if: None, + application_mode: ApplicationMode::Single, + }, + TemplateConfig { + pattern: Glob::new("**/attribute_group.md").expect("Invalid pattern"), + filter: Filter::try_new(".groups[] | select(.type == \"attribute_group\")") + .expect("Invalid filter"), + r#if: None, + application_mode: ApplicationMode::Each, + }, + TemplateConfig { + pattern: Glob::new("**/attribute_groups.md").expect("Invalid pattern"), + filter: Filter::try_new(".groups[] | select(.type == \"attribute_group\")") + .expect("Invalid filter"), + r#if: None, + application_mode: ApplicationMode::Single, + }, + TemplateConfig { + pattern: Glob::new("**/event.md").expect("Invalid pattern"), + filter: Filter::try_new(".groups[] | select(.type == \"event\")") + .expect("Invalid filter"), + r#if: None, + application_mode: ApplicationMode::Each, + }, + TemplateConfig { + pattern: Glob::new("**/events.md").expect("Invalid pattern"), + filter: Filter::try_new(".groups[] | select(.type == \"event\")") + .expect("Invalid filter"), + r#if: None, + application_mode: ApplicationMode::Single, + }, + TemplateConfig { + pattern: Glob::new("**/group.md").expect("Invalid pattern"), + filter: Filter::try_new(".groups").expect("Invalid filter"), + r#if: None, + application_mode: ApplicationMode::Each, + }, + TemplateConfig { + pattern: Glob::new("**/groups.md").expect("Invalid pattern"), + filter: Filter::try_new(".groups").expect("Invalid filter"), + r#if: None, + application_mode: ApplicationMode::Single, + }, + TemplateConfig { + pattern: Glob::new("**/metric.md").expect("Invalid pattern"), + filter: Filter::try_new(".groups[] | select(.type == \"metric\")") + .expect("Invalid filter"), + r#if: None, + application_mode: ApplicationMode::Each, + }, + TemplateConfig { + pattern: Glob::new("**/metrics.md").expect("Invalid pattern"), + filter: Filter::try_new(".groups[] | select(.type == \"metric\")") + .expect("Invalid filter"), + r#if: None, + application_mode: ApplicationMode::Single, + }, + TemplateConfig { + pattern: Glob::new("**/resource.md").expect("Invalid pattern"), + filter: Filter::try_new(".groups[] | select(.type == \"resource\")") + .expect("Invalid filter"), + r#if: None, + application_mode: ApplicationMode::Each, + }, + TemplateConfig { + pattern: Glob::new("**/resources.md").expect("Invalid pattern"), + filter: Filter::try_new(".groups[] | select(.type == \"resource\")") + .expect("Invalid filter"), + r#if: None, + application_mode: ApplicationMode::Single, + }, + TemplateConfig { + pattern: Glob::new("**/scope.md").expect("Invalid pattern"), + filter: Filter::try_new(".groups[] | select(.type == \"scope\")") + .expect("Invalid filter"), + r#if: None, + application_mode: ApplicationMode::Each, + }, + TemplateConfig { + pattern: Glob::new("**/scopes.md").expect("Invalid pattern"), + filter: Filter::try_new(".groups[] | select(.type == \"scope\")") + .expect("Invalid filter"), + r#if: None, + application_mode: ApplicationMode::Single, + }, + TemplateConfig { + pattern: Glob::new("**/span.md").expect("Invalid pattern"), + filter: Filter::try_new(".groups[] | select(.type == \"span\")") + .expect("Invalid filter"), + r#if: None, + application_mode: ApplicationMode::Each, + }, + TemplateConfig { + pattern: Glob::new("**/spans.md").expect("Invalid pattern"), + filter: Filter::try_new(".groups[] | select(.type == \"span\")") + .expect("Invalid filter"), + r#if: None, + application_mode: ApplicationMode::Single, + }, + ] +} + /// Parameters defined in the command line via the `--params` argument. #[derive(Deserialize, Debug, Clone, Default)] pub struct Params { diff --git a/src/registry/generate.rs b/src/registry/generate.rs index fc525fb8..de371385 100644 --- a/src/registry/generate.rs +++ b/src/registry/generate.rs @@ -40,7 +40,7 @@ pub struct RegistryGenerateArgs { /// Parameters key=value, defined in the command line, to pass to the templates. /// The value must be a valid YAML value. - #[arg(long, value_parser = parse_key_val)] + #[arg(short= 'D', long, value_parser = parse_key_val)] pub param: Option>, /// Parameters, defined in a YAML file, to pass to the templates.