youtube-legend-cli 0.4.0

Non-interactive Rust CLI that downloads YouTube subtitles through third-party providers, using a native Unix stdin/stdout interface.
//! The three arguments that shape diagnostic output.
//!
//! Split out of `cli.rs` on 2026-09-04 under GAP-2026-074. Log level,
//! log format and colour are one decision — how does this run talk about
//! itself? — and they read as one unit here in a way they never did
//! wedged between language parsing and provider selection.

use super::*;

/// Tracing log level. Maps to canonical `tracing` level names so
/// downstream subscribers parse the value without translation.
#[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum)]
#[non_exhaustive]
pub enum LogLevelArg {
    /// Only errors are reported.
    Error,
    /// Warnings and errors.
    Warn,
    /// Informational messages and above (default).
    Info,
    /// Diagnostic detail for debugging.
    Debug,
    /// Maximum verbosity for trace-level inspection.
    Trace,
}

impl LogLevelArg {
    /// Canonical `tracing` level name.
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::Error => "error",
            Self::Warn => "warn",
            Self::Info => "info",
            Self::Debug => "debug",
            Self::Trace => "trace",
        }
    }
}

impl LogFormatArg {
    /// Lowercase formatter name.
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::Text => "text",
            Self::Json => "json",
        }
    }
}

impl ColorArg {
    /// Lowercase colour policy name.
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::Auto => "auto",
            Self::Always => "always",
            Self::Never => "never",
        }
    }
}

/// Format for log output. `text` is human-readable; `json` produces
/// structured log records suitable for ingestion by aggregators.
#[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum)]
#[non_exhaustive]
pub enum LogFormatArg {
    /// Human-readable, line-oriented text (default).
    Text,
    /// Structured JSON log records, one per line.
    Json,
}

/// Color policy for terminal output. Mirrors the `clap` convention
/// used by `ripgrep`, `bat`, and other modern CLIs.
#[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum)]
#[non_exhaustive]
pub enum ColorArg {
    /// Decide from TTY detection at the point of output (default).
    Auto,
    /// Always emit ANSI colour escapes.
    Always,
    /// Never emit ANSI colour escapes.
    Never,
}