aam 0.3.0

AAM CLI is a CLI for AAM (learn more about AAM at https://aam.ininids.in.rs)
// SPDX-FileCopyrightText: 2026 Nikita Goncharov
// SPDX-License-Identifier: GPL-3.0-or-later

/// Strips ANSI escape codes from a string.
///
/// This function parses the input character by character, detecting ANSI escape
/// sequences (starting with `\u{001b}`) and skipping them entirely.
#[must_use]
pub fn strip_ansi_codes(s: &str) -> String {
    let mut result = String::with_capacity(s.len());
    let mut chars = s.chars().peekable();

    while let Some(ch) = chars.next() {
        if ch == '\u{001b}' {
            chars.next(); // skip '[' or next char
            while let Some(&next_ch) = chars.peek() {
                chars.next();
                if next_ch.is_alphabetic() {
                    break;
                }
            }
        } else {
            result.push(ch);
        }
    }

    result
}