espforge_lib/nibblers/
template.rs

1use crate::{
2    config::EspforgeConfiguration,
3    nibblers::{ConfigNibbler, NibblerResult, NibblerStatus},
4    register_nibbler,
5};
6use espforge_macros::auto_register_nibbler;
7
8#[derive(Default)]
9#[auto_register_nibbler]
10pub struct TemplateNibbler;
11
12impl ConfigNibbler for TemplateNibbler {
13    fn name(&self) -> &str {
14        "TemplateNibbler"
15    }
16
17    fn priority(&self) -> u8 {
18        1
19    }
20
21    fn process(&self, config: &EspforgeConfiguration) -> Result<NibblerResult, String> {
22        let mut findings = Vec::new();
23        let status = NibblerStatus::Ok;
24
25        if let Some(template) = config.get_template() {
26            findings.push(format!("Using template: {}", template));
27
28            // Example specific check
29            if template == "blink"
30                && let Some(ex) = &config.example
31                && !ex.example_properties.contains_key("blink_rate_ms")
32            {
33                findings.push("Note: 'blink_rate_ms' not set. Using template default.".to_string());
34            }
35        } else {
36            findings.push("No example template specified. Using minimal default.".to_string());
37        }
38
39        Ok(NibblerResult {
40            nibbler_name: self.name().to_string(),
41            findings,
42            status,
43        })
44    }
45}