scraps 3.6.0

Scraps is a portable CLI knowledge hub for managing interconnected Markdown documentation with Wiki-link notation.
pub use anyhow;

use std::path::PathBuf;

use thiserror::Error;

pub type ScrapsResult<T> = anyhow::Result<T>;

#[derive(Error, PartialEq, Debug)]
pub enum ScrapsError {
    #[error("Init error: {0}")]
    Init(#[from] InitError),

    #[error("Build error: {0}")]
    Build(#[from] BuildError),

    #[error("CLI error: {0}")]
    Cli(#[from] CliError),

    #[error("MCP error: {0}")]
    Mcp(#[from] McpError),

    #[error("Failed to read scrap: {0}")]
    ReadScrap(PathBuf),

    #[error("Failed to read scraps")]
    ReadScraps,

    #[error(
        "{} and {} are the same scrap: their names differ only in Unicode normalization form. Keep one of them.",
        .0.display(),
        .1.display()
    )]
    SameKey(PathBuf, PathBuf),
}

#[derive(Error, PartialEq, Debug)]
pub enum InitError {
    #[error("Failed to write file: {0}")]
    WriteFailure(PathBuf),
}

#[derive(Error, PartialEq, Debug)]
pub enum BuildError {
    #[error("Failed to get commited timestamp")]
    GitCommitedTs,

    #[error("Failed to create directory")]
    CreateDir,

    #[error("Failed to write file: {0}")]
    WriteFailure(PathBuf),

    #[error("Failed to render: {0}")]
    RenderFailure(PathBuf),

    #[error("Failed to render html")]
    RenderHtml,

    #[error("Failed to render css")]
    RenderCss,

    #[error("Failed to render json")]
    RenderJson,
}

#[derive(Error, PartialEq, Debug)]
pub enum ServeError {
    #[error("Failed to load file")]
    LoadFile,
}

#[derive(Error, PartialEq, Debug)]
pub enum CliError {
    #[error("Not display data on cli")]
    Display,

    #[error(
        "Failed to load .scraps.toml. See: https://boykush.github.io/scraps/scraps/Reference/Configuration.html"
    )]
    ConfigLoad,

    #[error(
        "Invalid .scraps.toml format. See: https://boykush.github.io/scraps/scraps/Reference/Configuration.html"
    )]
    InvalidConfigFormat,

    #[error(
        "Missing [ssg] section in .scraps.toml. This section is required for build and serve commands. See: https://boykush.github.io/scraps/scraps/Reference/Configuration.html"
    )]
    MissingSsgSection,
}

#[derive(Error, PartialEq, Debug)]
pub enum McpError {
    #[error("Failed to setup tracing for MCP server: {0}")]
    TracingSetup(String),

    #[error("MCP service error: {0}")]
    ServiceError(String),

    #[error("Failed to create tokio runtime: {0}")]
    RuntimeCreation(String),

    #[error("Failed to bind MCP server to {0}")]
    Bind(String),

    #[error("Failed to install the shutdown signal handler for MCP server: {0}")]
    SignalSetup(String),
}