cli-boxes 0.1.1

Unicode box drawing characters for creating beautiful CLI interfaces
Documentation
//! Basic usage example for the cli-boxes crate.
//!
//! This example shows the most common use cases:
//! - Using predefined box styles
//! - Creating simple boxes
//! - Basic customization

use cli_boxes::{BorderStyle, BoxChars};

fn main() {
    println!("📦 CLI Boxes - Basic Example\n");

    // Using predefined styles
    println!("Using predefined styles:");
    draw_simple_box("Hello, World!", BoxChars::SINGLE);
    draw_simple_box("Important Notice", BoxChars::DOUBLE);
    draw_simple_box("Friendly Message", BoxChars::ROUND);

    // Using BorderStyle enum
    println!("Using BorderStyle enum:");
    let style = BorderStyle::Bold;
    draw_simple_box("Bold Statement", style.chars());

    // Custom box with builder
    println!("Custom box with builder:");
    let custom = BoxChars::builder()
        .corners('*')
        .horizontal('-')
        .vertical('|')
        .build();
    draw_simple_box("Custom Style", custom);

    // Parsing from string
    println!("Parsing from string:");
    if let Ok(parsed_style) = "round".parse::<BorderStyle>() {
        draw_simple_box("Parsed Style", parsed_style.chars());
    }
}

/// Draw a simple box around text
fn draw_simple_box(text: &str, chars: BoxChars) {
    let width = text.len() + 2; // Add padding

    // Top border
    print!("{}", chars.top_left);
    print!("{}", chars.top.to_string().repeat(width));
    println!("{}", chars.top_right);

    // Content with side borders
    println!("{} {} {}", chars.left, text, chars.right);

    // Bottom border
    print!("{}", chars.bottom_left);
    print!("{}", chars.bottom.to_string().repeat(width));
    println!("{}", chars.bottom_right);

    println!(); // Extra spacing
}