Repository: starship/starship
File: src/configure.rs (Rust)

Code before:
    }
}

pub fn print_configuration(use_default: bool) {
    let config = if use_default {
        // Get default config
        let default_config = crate::configs::FullConfig::default();
        // Convert back to Value because toml can't serialize FullConfig directly
        toml::value::Value::try_from(default_config).unwrap()
    } else {
        // Get config as toml::Value
        let user_config = get_configuration();
        // Convert into FullConfig and fill in default values
        let user_config = crate::configs::FullConfig::try_load(Some(&user_config));
        // Convert back to Value because toml can't serialize FullConfig directly
        toml::value::Value::try_from(user_config).unwrap()
    };

    let string_config = toml::to_string_pretty(&config).unwrap();

    println!("# Warning: This config does not include keys that have an unset value\n");
    println!(
        "# $all is shorthand for {}",
        PROMPT_ORDER
            .iter()
            .map(|module_name| format!("${}", module_name))
            .collect::<String>()
    );
    println!("{}", string_config);
}

pub fn toggle_configuration(name: &str, key: &str) {
    if let Some(table) = get_configuration().as_table_mut() {
        match table.get(name) {
            Some(v) => {
                if let Some(values) = v.as_table() {
                    let mut updated_values = values.clone();

                    let current: bool = match updated_values.get(key) {
                        Some(v) => match v.as_bool() {
                            Some(b) => b,
                            _ => {
                                log::error!(
                                    "Given config key '{}' must be in 'boolean' format",
                                    key
                                );
                                process::exit(1);
                            }
                        },
                        _ => {
                            log::error!("Given config key '{}' must be exist in config file", key);

Review comment (bug):
For custom modules, you need `${custom.whatever}`, would prevent many debugging sessions if all of them would have that (at least it would have prevented me from wasting like an hour on this on two different occasions...).

Code after:
    }
}

pub fn print_configuration(use_default: bool) {
    let config = if use_default {
        // Get default config
        let default_config = crate::configs::FullConfig::default();
        // Convert back to Value because toml can't serialize FullConfig directly
        toml::value::Value::try_from(default_config).unwrap()
    } else {
        // Get config as toml::Value
        let user_config = get_configuration();
        // Convert into FullConfig and fill in default values
        let user_config = crate::configs::FullConfig::try_load(Some(&user_config));
        // Convert back to Value because toml can't serialize FullConfig directly
        toml::value::Value::try_from(user_config).unwrap()
    };

    let string_config = toml::to_string_pretty(&config).unwrap();

    println!("# Warning: This config does not include keys that have an unset value\n");
    println!(
        "# $all is shorthand for {}",
        PROMPT_ORDER
            .iter()
            .map(|module_name| format!("${}", module_name))
            .collect::<String>()
    );

    // Unwrapping is fine because config is based on FullConfig
    let custom_modules = config.get("custom").unwrap().as_table().unwrap();
    if !use_default && !custom_modules.is_empty() {
        println!(
            "# $custom (excluding any modules already listed in `format`) is shorthand for {}",
            custom_modules
                .keys()
                .map(|module_name| format!("${{custom.{}}}", module_name))
                .collect::<String>()
        );
    }
    println!("{}", string_config);
}

pub fn toggle_configuration(name: &str, key: &str) {
    if let Some(table) = get_configuration().as_table_mut() {
        match table.get(name) {
            Some(v) => {
                if let Some(values) = v.as_table() {
                    let mut updated_values = values.clone();

                    let current: bool = match updated_values.get(key) {