fn apply_config_overrides()

in src/main.rs [30:81]


fn apply_config_overrides(config: &mut Config, matches: &ArgMatches) {
    // We allow specifying a language to override the config default. This is
    // used by compile-tests.
    match matches.try_get_one::<String>("lang") {
        Ok(Some(lang)) => {
            config.language = bindgen::Language::from_str(lang).unwrap();
        }
        Err(reason) => {
            error!("{}", reason);
            return;
        }
        _ => (),
    }

    if matches.get_flag("cpp-compat") {
        config.cpp_compat = true;
    }

    if matches.get_flag("only-target-dependencies") {
        config.only_target_dependencies = true;
    }

    if matches.get_flag("package-version") {
        config.package_version = true;
    }

    match matches.try_get_one::<String>("style") {
        Ok(Some(style)) => {
            config.style = bindgen::Style::from_str(style).unwrap();
        }
        Err(_) => {
            error!("Unknown style specified.");
            return;
        }
        _ => (),
    }

    match matches.try_get_one::<String>("profile") {
        Ok(Some(profile)) => {
            config.parse.expand.profile = bindgen::Profile::from_str(profile).unwrap();
        }
        Err(e) => {
            error!("{}", e);
            return;
        }
        _ => (),
    }

    if matches.get_flag("d") {
        config.parse.parse_deps = true;
    }
}