summaryrefslogtreecommitdiffstats
path: root/src/options.rs
diff options
context:
space:
mode:
authorClementTsang <cjhtsang@uwaterloo.ca>2020-11-21 14:49:44 -0500
committerClementTsang <cjhtsang@uwaterloo.ca>2020-11-21 14:49:44 -0500
commit99d04029f0ebfc73d36adb06ea58ad68f090017c (patch)
treea6b02fbb7eb76552109e69c76b26c6ff1a199cec /src/options.rs
parent6ef1d66b2bca49452572a2cabb87d338dcf56e7b (diff)
bug: [skip travis] Add a better check for default colors in the config file
Diffstat (limited to 'src/options.rs')
-rw-r--r--src/options.rs25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/options.rs b/src/options.rs
index 21da8427..7e8da0a7 100644
--- a/src/options.rs
+++ b/src/options.rs
@@ -192,6 +192,18 @@ pub struct ConfigColours {
pub low_battery_color: Option<String>,
}
+impl ConfigColours {
+ pub fn is_empty(&self) -> bool {
+ if let Ok(serialized_string) = toml::to_string(self) {
+ if !serialized_string.is_empty() {
+ return false;
+ }
+ }
+
+ true
+ }
+}
+
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct IgnoreList {
pub is_list_ignored: bool,
@@ -918,9 +930,16 @@ pub fn get_color_scheme(
if let Some(color) = matches.value_of("color") {
// Highest priority is always command line flags...
return ColourScheme::from_str(color);
- } else if config.colors.is_some() {
- // Then, give priority to custom colours...
- return Ok(ColourScheme::Custom);
+ } else if let Some(colors) = &config.colors {
+ if !colors.is_empty() {
+ // Then, give priority to custom colours...
+ return Ok(ColourScheme::Custom);
+ } else if let Some(flags) = &config.flags {
+ // Last priority is config file flags...
+ if let Some(color) = &flags.color {
+ return ColourScheme::from_str(color);
+ }
+ }
} else if let Some(flags) = &config.flags {
// Last priority is config file flags...
if let Some(color) = &flags.color {