use crate::config;

/// Load configuration, validate it, and fall back to defaults on error.
///
/// Non-fatal failures are logged to stderr but do not prevent startup.
pub fn load_settings() -> config::Settings {
    match config::Settings::load() {
        Ok(s) => {
            if let Err(msg) = s.validate() {
                eprintln!("presto: invalid config, using defaults: {msg}");
                config::Settings::default()
            } else {
                s
            }
        }
        Err(e) => {
            // Config is optional; failures should not prevent the app from starting.
            eprintln!("presto: failed to load config, using defaults: {e}");
            config::Settings::default()
        }
    }
}
