Skip to content

Commit 872b9cc

Browse files
committed
separate config options for key and value case
1 parent ab18161 commit 872b9cc

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

docs/example_config.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
ascii = "stack"
33
seperator = ": "
44
modules = ["os", "desktop", "shell", "uptime"]
5-
lowercase = false
5+
key_lowercase = false # true: "os", false: "OS"
6+
value_lowercase = false # true: "debian", false: "Debian"
67

78
[colours]
89
primary = "\u001B[39m" # reset

src/config/config.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ pub struct DisplayConfig {
1414
pub ascii: String,
1515
pub seperator: String,
1616
pub modules: Vec<String>,
17-
pub lowercase: bool,
17+
pub key_lowercase: bool,
18+
pub value_lowercase: bool,
1819
}
1920

2021
#[derive(Deserialize, Serialize)]
@@ -34,7 +35,8 @@ pub fn default() -> Config {
3435
"shell".to_string(),
3536
"uptime".to_string(),
3637
],
37-
lowercase: false,
38+
key_lowercase: false,
39+
value_lowercase: false,
3840
},
3941
colours: ColoursConfig {
4042
primary: "\x1B[39m".to_string(),

src/main.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,18 @@ fn main() -> Result<(), Box<dyn Error>> {
3535
continue;
3636
}
3737

38-
let (key, mut value) = match module_name {
39-
"os" => ("OS", data::os::distro()),
40-
"desktop" => ("DE", data::desktop::desktop()),
41-
"shell" => ("SH", data::shell::shell()),
42-
"uptime" => ("UP", data::uptime::uptime()),
38+
let (mut key, mut value) = match module_name {
39+
"os" => ("OS".to_string(), data::os::distro()),
40+
"desktop" => ("DE".to_string(), data::desktop::desktop()),
41+
"shell" => ("SH".to_string(), data::shell::shell()),
42+
"uptime" => ("UP".to_string(), data::uptime::uptime()),
4343
_ => return Err(format!("unknown module '{}'", module_name).into()),
4444
};
4545

46-
if cfg.display.lowercase {
46+
if cfg.display.key_lowercase {
47+
key = key.to_lowercase()
48+
}
49+
if cfg.display.value_lowercase {
4750
value = value.to_lowercase();
4851
}
4952

0 commit comments

Comments
 (0)