is_color_enabled (src/style.rs)

xberg · crates/xberg-cli/src/style.rs · rust · MIT
ui, tag:embed-classified

Utility functions for styling CLI output with ANSI colors, respecting NO_COLOR.

// Source: https://github.com/xberg-io/xberg | License: MIT | Copyright 2025-2026 Kreuzberg, Inc
// Provided via justclaw.it.com; keep this notice with the code.
//! CLI color styling helpers using `anstyle`.
//!
//! Provides styled output for the xberg CLI. Respects the `NO_COLOR`
//! environment variable (<https://no-color.org/>) and disables colors
//! when output is not a terminal.

use anstyle::{AnsiColor, Effects, Style};
use std::sync::OnceLock;

/// Bold blue for section headers.
const HEADER: Style = Style::new()
    .fg_color(Some(anstyle::Color::Ansi(AnsiColor::Blue)))
    .effects(Effects::BOLD);

/// Green for success values (MIME types, file paths, versions).
const SUCCESS: Style = Style::new().fg_color(Some(anstyle::Color::Ansi(AnsiColor::Green)));

/// Yellow for warnings: 

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key