exor 0.1.1

Batteries included cli tool for generating git fork diff documentation websites via YAML configuration files.
Documentation
use serde::{Deserialize, Serialize};

/// The exor Fork Config YAML
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct ForkConfig {
    /// The site title.
    /// If the title is not provided, the default value
    /// `EXOR Generated Fork Diff Site` will be used.
    pub title: String,
    /// The site logo.
    /// If the logo is not provided, the default value
    /// `https://raw.githubusercontent.com/refcell/exor/main/etc/logo.png` will be used.
    /// The logo must be a valid URL.
    #[serde(skip_serializing_if = "String::is_empty")]
    pub logo: String,
    /// The site footer. An optional value.
    /// If no footer is specified, the generated site will not have a footer.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub footer: Option<String>,
    /// The Base [Source] Object.
    #[serde(skip_serializing_if = "Source::is_default")]
    pub base: Source,
    /// The Fork [Source] Object.
    #[serde(skip_serializing_if = "Source::is_default")]
    pub fork: Source,
    /// The fork diff site definition.
    #[serde(skip_serializing_if = "Section::is_default")]
    pub def: Section,
    /// Glob paths to exclude from the diff.
    #[serde(skip_serializing_if = "Vec::is_empty")]
    pub ignore: Vec<String>,
}

/// A Site Definition Section
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct Section {
    /// The site title
    pub title: String,
    /// Description
    pub description: String,
    /// Globs
    pub globs: Vec<String>,
    /// Sub-sections
    #[serde(skip_serializing_if = "Vec::is_empty")]
    pub sub: Vec<Box<Section>>,
}

impl Section {
    /// Returns true if the section is default.
    pub fn is_default(&self) -> bool {
        self == &Section::default()
    }
}

/// A Source Object
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct Source {
    /// The source name.
    pub name: String,
    /// The source description.
    pub description: String,
    /// The source config.
    #[serde(flatten)]
    pub config: SourceConfig,
}

impl Source {
    /// Returns true if the source is default.
    pub fn is_default(&self) -> bool {
        self == &Source::default()
    }
}

/// Git Source
///
/// A git source is an enum with internal fields that hold configuration
/// for the git source.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SourceConfig {
    /// A git source that is a local git repository.
    Local(String),
    /// A git source that is a remote git repository.
    Git(GitSource),
}

impl Default for SourceConfig {
    fn default() -> Self {
        SourceConfig::Git(GitSource::default())
    }
}

/// A Git Repository Source
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct GitSource {
    /// The name of the git
    /// The git repository URL.
    pub url: String,
    /// The git reference.
    pub r#ref: String,
    /// The git repository branch.
    pub branch: String,
}