Experimenting with more structured ways to handle command-line input/output in Rust
use fluent_langneg::NegotiationStrategy;
use icu_locid::LanguageIdentifier;

mod fetch;
pub mod unix;

pub fn match_locales(
    available: &[LanguageIdentifier],
    default: &LanguageIdentifier,
) -> Vec<LanguageIdentifier> {
    // TODO: requesting locales should have platform-specific logic
    let requested = unix::get_locales(fetch::unix::LocaleCategory::Messages);
    let supported = fluent_langneg::negotiate_languages(
        &requested,
        &available,
        Some(&default),
        NegotiationStrategy::Matching,
    );

    // TODO: this is wasteful but avoids dealing with lifetimes for now
    supported.into_iter().cloned().collect()
}