nestrs-cli-rs 0.1.0

Rust port of the Nest CLI for the nestrs organization.
Documentation
//! Upstream source: `../nest-cli/lib/utils/formatting.ts`.

/// Normalizes input to the path/file naming style supported by Nest schematics.
///
/// This mirrors upstream `normalizeToKebabOrSnakeCase`: decamelize ASCII
/// camelCase boundaries, lowercase the result, replace whitespace with `-`,
/// and preserve existing underscores.
pub fn normalize_to_kebab_or_snake_case(value: &str) -> String {
    let mut output = String::with_capacity(value.len());
    let mut previous: Option<char> = None;

    for character in value.chars() {
        if character.is_ascii_uppercase()
            && previous
                .is_some_and(|previous| previous.is_ascii_lowercase() || previous.is_ascii_digit())
        {
            output.push('-');
        }

        if character.is_whitespace() {
            output.push('-');
        } else {
            output.push(character.to_ascii_lowercase());
        }

        previous = Some(character);
    }

    output
}