moon_config 2.0.13

Core workspace, project, and moon configuration.
Documentation
use crate::config_struct;
use crate::shapes::FilePath;
use crate::template::TemplateLocator;
use schematic::{Config, DefaultValueResult, validate};

fn default_templates<C>(_ctx: &C) -> DefaultValueResult<Vec<TemplateLocator>> {
    Ok(Some(vec![TemplateLocator::File {
        path: FilePath("./templates".into()),
    }]))
}

config_struct!(
    /// Configures the generator for scaffolding from templates.
    #[derive(Config)]
    pub struct GeneratorConfig {
        /// The list of file paths, relative from the workspace root,
        /// in which to locate templates.
        #[setting(
            validate = validate::not_empty,
            default = default_templates
        )]
        #[serde(default, skip_serializing_if = "Vec::is_empty")]
        pub templates: Vec<TemplateLocator>,
    }
);