Skip to content

Commit

Permalink
Implemented colourise_wx_code().
Browse files Browse the repository at this point in the history
  • Loading branch information
RRArny committed Aug 15, 2024
1 parent 8f7a9d8 commit d3a6a67
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@ For wxfetch to work you will need a free account on https://avwx.rest/. Once you

## Todos

- [ ] colourise_wx_code()
- [ ] Personal wx minima

- [ ] Configuration options
26 changes: 24 additions & 2 deletions src/metar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,30 @@ fn colourise_wx_code(
proximity: &WxCodeProximity,
descriptor: &WxCodeDescription,
) -> ColoredString {
// TODO
format!("{intensity}{descriptor}{code}{proximity}").magenta()
let codestr = format!("{code}").color(match code {
WxCode::Ra => Color::BrightYellow,
WxCode::Gr => Color::Red,
WxCode::Gs => Color::Yellow,
WxCode::Sn => Color::Red,
WxCode::Up => Color::Red,
WxCode::Po => Color::BrightRed,
_ => Color::White,
});

let intensitystr = format!("{intensity}").color(match intensity {
WxCodeIntensity::Light => Color::BrightGreen,
WxCodeIntensity::Heavy => Color::BrightRed,
_ => Color::White,
});

let descrstr = format!("{descriptor}").color(match descriptor {
WxCodeDescription::Ts => Color::Red,
WxCodeDescription::Fz => Color::BrightBlue,
WxCodeDescription::Sh => Color::Yellow,
_ => Color::White,
});

format!("{intensitystr}{descrstr}{codestr}{proximity}").magenta()
}

fn colourise_qnh(qnh: &i64, unit: &PressureUnit) -> ColoredString {
Expand Down

0 comments on commit d3a6a67

Please sign in to comment.