fix: only print root level config logs a single time (#3132)

This commit is contained in:
David Knaack
2021-10-27 15:13:17 +02:00
committed by GitHub
parent b2c48358c3
commit c4439531d3
6 changed files with 41 additions and 33 deletions
+6 -9
View File
@@ -1,4 +1,3 @@
use crate::configs::StarshipRootConfig;
use crate::utils;
use ansi_term::{Color, Style};
use indexmap::IndexMap;
@@ -63,6 +62,12 @@ impl<'a> ModuleConfig<'a> for &'a str {
}
}
impl<'a> ModuleConfig<'a> for String {
fn from_config(config: &'a Value) -> Option<Self> {
config.as_str().map(std::borrow::ToOwned::to_owned)
}
}
impl<'a> ModuleConfig<'a> for Style {
fn from_config(config: &Value) -> Option<Self> {
parse_style_string(config.as_str()?)
@@ -346,14 +351,6 @@ impl StarshipConfig {
pub fn get_env_var_modules(&self) -> Option<&toml::value::Table> {
self.get_config(&["env_var"])?.as_table()
}
pub fn get_root_config(&self) -> StarshipRootConfig {
if let Some(root_config) = &self.config {
StarshipRootConfig::load(root_config)
} else {
StarshipRootConfig::default()
}
}
}
/** Parse a style string which represents an ansi style. Valid tokens in the style