guardy 0.2.4

Fast, secure git hooks in Rust with secret scanning and protected file synchronization
Documentation
//! Shared banner/branding display for guardy commands

use console::measure_text_width;
use supercli::starbase_styles::color::owo::OwoColorize;

/// Print the guardy banner with consistent styling
///
/// # Arguments
/// * `context` - Optional context text (e.g., "hook: pre-commit", "status", "version")
pub fn print_banner(context: Option<&str>) {
    const VERSION: &str = env!("CARGO_PKG_VERSION");
    let git_sha = option_env!("GIT_SHA").unwrap_or("unknown");

    let formatted_text = if let Some(ctx) = context {
        format!(
            " 🛡️  {} {} ({})  {} ",
            "guardy".bright_magenta(),
            format!("v{}", VERSION).dimmed(),
            git_sha.dimmed(),
            ctx
        )
    } else {
        format!(
            " 🛡️  {} {} ({}) ",
            "guardy".bright_magenta(),
            format!("v{}", VERSION).dimmed(),
            git_sha.dimmed()
        )
    };

    // Calculate width by stripping ANSI codes
    let text_width = measure_text_width(&formatted_text);
    let border = "".repeat(text_width - 1);

    // Print with dimmed box borders
    println!("{}{}{}", "".dimmed(), border.dimmed(), "".dimmed());
    println!("{}{}{}", "".dimmed(), formatted_text, "".dimmed());
    println!("{}{}{}", "".dimmed(), border.dimmed(), "".dimmed());
}