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

Code before:
        "bright-green" => Some(Color::Fixed(10)),
        "bright-yellow" => Some(Color::Fixed(11)),
        "bright-blue" => Some(Color::Fixed(12)),
        "bright-purple" => Some(Color::Fixed(13)),
        "bright-cyan" => Some(Color::Fixed(14)),
        "bright-white" => Some(Color::Fixed(15)),
        _ => None,
    };

    if predefined_color.is_some() {
        log::trace!("Read predefined color: {}", color_string);
    } else {
        log::debug!("Could not parse color in string: {}", color_string);
    }
    predefined_color
}

fn get_palette<'a>(
    palettes: &'a HashMap<String, Palette>,
    palette_name: &str,
) -> Option<&'a Palette> {
    let palette = palettes.get(palette_name);
    if palette.is_some() {
        log::trace!("Found color palette: {}", palette_name);
    } else {
        log::debug!("Could not find color palette: {}", palette_name);
    }
    palette
}

#[cfg(test)]
mod tests {
    use super::*;
    use ansi_term::Style;

    // Small wrapper to allow deserializing Style without a struct with #[serde(deserialize_with=)]
    #[derive(Default, Clone, Debug, PartialEq)]
    struct StyleWrapper(Style);

    impl<'de> Deserialize<'de> for StyleWrapper {
        fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
        where
            D: Deserializer<'de>,
        {
            deserialize_style(deserializer).map(Self)
        }
    }

    #[test]
    fn test_load_config() {
        #[derive(Clone, Default, Deserialize)]

Review comment (bug):
Not a blocker but maybe it would be better to log this as a warning to let the user know that they have something wrong with their configuration? 

Code after:
        "black" => Some(Color::Black),
        "red" => Some(Color::Red),
        "green" => Some(Color::Green),
        "yellow" => Some(Color::Yellow),
        "blue" => Some(Color::Blue),
        "purple" => Some(Color::Purple),
        "cyan" => Some(Color::Cyan),
        "white" => Some(Color::White),
        "bright-black" => Some(Color::DarkGray), // "bright-black" is dark grey
        "bright-red" => Some(Color::LightRed),
        "bright-green" => Some(Color::LightGreen),
        "bright-yellow" => Some(Color::LightYellow),
        "bright-blue" => Some(Color::LightBlue),
        "bright-purple" => Some(Color::LightPurple),
        "bright-cyan" => Some(Color::LightCyan),
        "bright-white" => Some(Color::LightGray),
        _ => None,
    };

    if predefined_color.is_some() {
        log::trace!("Read predefined color: {}", color_string);
    } else {
        log::debug!("Could not parse color in string: {}", color_string);
    }
    predefined_color
}

fn get_palette<'a>(
    palettes: &'a HashMap<String, Palette>,
    palette_name: Option<&str>,
) -> Option<&'a Palette> {
    if let Some(palette_name) = palette_name {
        let palette = palettes.get(palette_name);
        if palette.is_some() {
            log::trace!("Found color palette: {}", palette_name);
        } else {
            log::warn!("Could not find color palette: {}", palette_name);
        }
        palette
    } else {
        log::trace!("No color palette specified, using defaults");
        None
    }
}

#[cfg(test)]
mod tests {
    use super::*;
    use nu_ansi_term::Style;

    // Small wrapper to allow deserializing Style without a struct with #[serde(deserialize_with=)]