/// A parsed entry from a Kv Format text.
///
/// Line numbers are 1-based for Kv text lines. The shebang line (if present)
/// is line 0.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Entry {
    /// A key-value data line. Always emitted.
    Kv {
        /// 1-based line number.
        line: u32,
        /// The key (leading/trailing whitespace stripped, validated).
        key: String,
        /// The value (verbatim, no escaping or interpolation).
        value: String,
    },
    /// A comment line. Emitted only when [`ParserConfig::emit_comments`] is `true`.
    Comment {
        /// 1-based line number.
        line: u32,
        /// Comment text after the `#` character (verbatim, EOL excluded).
        text: String,
    },
    /// A blank line (contains only optional whitespace). Emitted only when
    /// [`ParserConfig::emit_blanks`] is `true`.
    Blank {
        /// 1-based line number.
        line: u32,
    },
    /// The shebang line (`#!…`), which is always line 0. Emitted only when
    /// [`ParserConfig::emit_shebang`] is `true`.
    Shebang {
        /// The full shebang text including the `#!` prefix, EOL excluded.
        text: String,
    },
}

/// Configuration for the Kv Format parser.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ParserConfig {
    /// Whether to emit [`Entry::Comment`] variants. Default: `true`.
    pub emit_comments: bool,
    /// Whether to emit [`Entry::Blank`] variants. Default: `false`.
    pub emit_blanks: bool,
    /// Whether to emit the [`Entry::Shebang`] variant. Default: `false`.
    pub emit_shebang: bool,
}

impl Default for ParserConfig {
    fn default() -> Self {
        ParserConfig {
            emit_comments: true,
            emit_blanks: false,
            emit_shebang: false,
        }
    }
}
