runandlog 0.7.0

CLI / TUI that runs the shell commands in a Markdown file and writes the results back
//! The licence of Run and Log and of the libraries compiled into it.
//!
//! Both texts are baked into the binary: what ships through Homebrew is the bare
//! executable, with no LICENSE file beside it, so `--license` and the window's
//! "Third-Party Licenses" item are the only places a user can read them.
//!
//! The files are symlinks to the ones at the top of the repository. They sit in
//! the crate rather than being reached with `../..`, because what is published to
//! crates.io is the crate directory alone and `cargo package` refuses a path that
//! leaves it. THIRD-PARTY-NOTICES.txt is generated by
//! `scripts/generate-third-party-notices.sh`; run it again after adding or
//! upgrading a dependency (`tests/third_party_notices.rs` fails until you do).

/// Run and Log's own licence (MIT).
pub const LICENSE: &str = include_str!("../LICENSE");

/// The licences of the libraries compiled into the binary.
pub const THIRD_PARTY_NOTICES: &str = include_str!("../THIRD-PARTY-NOTICES.txt");

/// What `--license` prints: Run and Log's own licence, then the third-party notices.
pub fn license_text() -> String {
    let rule = "#".repeat(80);
    format!(
        "{rule}\n# Run and Log\n{rule}\n\n{}\n\n{}",
        LICENSE.trim_end(),
        THIRD_PARTY_NOTICES
    )
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn the_license_text_starts_with_our_own_licence_and_carries_the_notices() {
        // Act
        let text = license_text();

        // Assert
        assert!(text.contains("# Run and Log\n"));
        assert!(text.contains("Copyright (c) 2026 Cyberneura"));
        assert!(text.contains("THIRD-PARTY NOTICES"));
        let own = text.find("Copyright (c) 2026 Cyberneura").unwrap();
        let notices = text.find("THIRD-PARTY NOTICES").unwrap();
        assert!(own < notices, "our own licence comes first");
    }
}