// Minimal color codes for CLI - no formatting, just basic ANSI
const std = @import("std");
const terminal = @import("terminal.zig");

pub const reset = "\x1b[0m";
pub const red = "\x1b[31m";
pub const green = "\x1b[32m";
pub const yellow = "\x1b[33m";
pub const blue = "\x1b[34m";
pub const bold = "\x1b[1m";

/// Check if colors should be used based on: flag > NO_COLOR > CLICOLOR_FORCE > TTY
pub fn shouldUseColor(force_flag: ?bool) bool {
    // Flag takes precedence
    if (force_flag) |forced| return forced;

    // Check NO_COLOR (any value disables colors)
    if (std.process.getEnvVarOwned(std.heap.page_allocator, "NO_COLOR")) |_| {
        return false;
    } else |_| {}

    // Check CLICOLOR_FORCE (any value enables colors)
    if (std.process.getEnvVarOwned(std.heap.page_allocator, "CLICOLOR_FORCE")) |_| {
        return true;
    } else |_| {}

    // Default: color if TTY
    return terminal.isTTY();
}

// Legacy function - uses auto-detection
pub fn shouldUseColorAuto() bool {
    return shouldUseColor(null);
}
