diff options
| author | Daniel Jankowski <daniel.jankowski@rub.de> | 2024-07-15 16:32:12 +0200 |
|---|---|---|
| committer | Daniel Jankowski <daniel.jankowski@rub.de> | 2024-07-15 16:32:12 +0200 |
| commit | 4fc37420c70a6d453fc831ea6fa7e69ea0b434b7 (patch) | |
| tree | 169f310f8ed9a36f2244b54840d09d88262744e3 /src/render.rs | |
| parent | feat: add color aliases (diff) | |
| download | sl0pstatus-4fc37420c70a6d453fc831ea6fa7e69ea0b434b7.tar.gz sl0pstatus-4fc37420c70a6d453fc831ea6fa7e69ea0b434b7.tar.xz sl0pstatus-4fc37420c70a6d453fc831ea6fa7e69ea0b434b7.zip | |
chore: move from {alias} to $alias
Diffstat (limited to 'src/render.rs')
| -rw-r--r-- | src/render.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/render.rs b/src/render.rs index 352cdbb..a9f55ef 100644 --- a/src/render.rs +++ b/src/render.rs @@ -301,8 +301,8 @@ fn hex_to_rgb(s: &str) -> anyhow::Result<Vec<u8>> { )] fn parse_color(color: &str, config: &BTreeMap<String, String>) -> Option<Color> { let mut color = color; - if color.starts_with('{') { - let alias_name = &color[1..color.len() - 1]; + if color.starts_with('$') { + let alias_name = color.strip_prefix('$').unwrap(); color = match config.get(&format!("color_{alias_name}")) { Some(color_str) => color_str, @@ -411,11 +411,11 @@ mod test { let result = parse_color("#365", &config); assert_eq!(result, None); - let result = parse_color("{green}", &config); + let result = parse_color("$green", &config); let expected = RgbColor(0, 255, 0); assert_eq!(result, Some(expected.into())); - let result = parse_color("{blue}", &config); + let result = parse_color("$blue", &config); assert_eq!(result, None); } } |
