⭐
Log in to mark this repository.
- Run fmt
72bb615 · gmorell · 2025-01-16 04:32
Message
{commit_body(@commit)}
Files changed
modified
.gitlab-ci.yml
+12
−0
@@ -23,6 +23,18 @@ test:cargo:
| 23 | 23 | - rustc --version && cargo --version # Print version info for debugging |
| 24 | 24 | - cargo test --workspace --verbose |
| 25 | 25 | |
| 26 | +# Use cargo to test the project | |
| 27 | +test:clippy: | |
| 28 | + script: | |
| 29 | + - rustc --version && cargo --version # Print version info for debugging | |
| 30 | + - cargo clippy | |
| 31 | + | |
| 32 | +# Use cargo to test the project | |
| 33 | +test:fmt: | |
| 34 | + script: | |
| 35 | + - rustc --version && cargo --version # Print version info for debugging | |
| 36 | + - cargo fmt --check | |
| 37 | + | |
| 26 | 38 | # Optional: Use a third party library to generate gitlab junit reports |
| 27 | 39 | test:junit-report: |
| 28 | 40 | script: |
modified
src/do_tui.rs
+126
−95
@@ -16,7 +16,7 @@ use itertools::Itertools;
| 16 | 16 | use ratatui::prelude::{Constraint, Direction, Layout, Line, Modifier, Span, Style, Stylize, Text}; |
| 17 | 17 | use ratatui::style::palette::material::AMBER; |
| 18 | 18 | use ratatui::style::palette::tailwind::{GREEN, ORANGE, PINK, SLATE, WHITE}; |
| 19 | −use ratatui::style::{Color}; | |
| 19 | +use ratatui::style::Color; | |
| 20 | 20 | use ratatui::widgets::calendar::{CalendarEventStore, Monthly}; |
| 21 | 21 | use ratatui::widgets::{Block, Borders, List, ListDirection, ListItem, ListState, Paragraph}; |
| 22 | 22 | use ratatui::{DefaultTerminal, Frame}; |
@@ -228,36 +228,27 @@ pub async fn run_tui(
| 228 | 228 | KeyCode::Char('f') => { |
| 229 | 229 | default_editing_handler(&mut app, &key_event); |
| 230 | 230 | } |
| 231 | − KeyCode::Char('c') => { | |
| 232 | − match app.current_tab { | |
| 233 | − Tabs::Ppl => { app.ppl_show_contacts = !app.ppl_show_contacts } | |
| 234 | − _ => {} | |
| 235 | − } | |
| 236 | − } | |
| 237 | − KeyCode::Char('d') => { | |
| 238 | − match app.current_tab { | |
| 239 | − Tabs::Ppl => { app.ppl_show_dates = !app.ppl_show_dates } | |
| 240 | − _ => {} | |
| 241 | − } | |
| 242 | − } | |
| 243 | − KeyCode::Char('r') => { | |
| 244 | − match app.current_tab { | |
| 245 | − Tabs::Ppl => { app.ppl_show_traits = !app.ppl_show_traits } | |
| 246 | − _ => {} | |
| 247 | − } | |
| 248 | − } | |
| 249 | − KeyCode::Char('i') => { | |
| 250 | − match app.current_tab { | |
| 251 | − Tabs::Ppl => { app.ppl_show_tiers = !app.ppl_show_tiers } | |
| 252 | − _ => {} | |
| 253 | − } | |
| 254 | − } | |
| 255 | − KeyCode::Char('l') => { | |
| 256 | − match app.current_tab { | |
| 257 | − Tabs::Ppl => { app.ppl_show_relations = !app.ppl_show_relations } | |
| 258 | − _ => {} | |
| 259 | − } | |
| 260 | − } | |
| 231 | + KeyCode::Char('c') => match app.current_tab { | |
| 232 | + Tabs::Ppl => app.ppl_show_contacts = !app.ppl_show_contacts, | |
| 233 | + Tabs::Calendar => {} | |
| 234 | + _ => {} | |
| 235 | + }, | |
| 236 | + KeyCode::Char('d') => match app.current_tab { | |
| 237 | + Tabs::Ppl => app.ppl_show_dates = !app.ppl_show_dates, | |
| 238 | + _ => {} | |
| 239 | + }, | |
| 240 | + KeyCode::Char('r') => match app.current_tab { | |
| 241 | + Tabs::Ppl => app.ppl_show_traits = !app.ppl_show_traits, | |
| 242 | + _ => {} | |
| 243 | + }, | |
| 244 | + KeyCode::Char('i') => match app.current_tab { | |
| 245 | + Tabs::Ppl => app.ppl_show_tiers = !app.ppl_show_tiers, | |
| 246 | + _ => {} | |
| 247 | + }, | |
| 248 | + KeyCode::Char('l') => match app.current_tab { | |
| 249 | + Tabs::Ppl => app.ppl_show_relations = !app.ppl_show_relations, | |
| 250 | + _ => {} | |
| 251 | + }, | |
| 261 | 252 | KeyCode::Enter => { |
| 262 | 253 | if app.current_tab == Tabs::Ppl { |
| 263 | 254 | if app.ppl_editing && app.ppl_detail_state.selected().is_some() { |
@@ -390,7 +381,7 @@ fn render(f: &mut Frame, app: &mut Tui) {
| 390 | 381 | Constraint::Percentage(100), |
| 391 | 382 | Constraint::Length(1), |
| 392 | 383 | ] |
| 393 | − .as_ref(), | |
| 384 | + .as_ref(), | |
| 394 | 385 | ) |
| 395 | 386 | .split(f.area()); |
| 396 | 387 |
@@ -442,41 +433,72 @@ fn render(f: &mut Frame, app: &mut Tui) {
| 442 | 433 | Span::raw(" to edit the selected ppl. "), |
| 443 | 434 | ]; |
| 444 | 435 | if app.ppl_show_contacts { |
| 445 | − msgw.push(Span::styled("C", Style::default().add_modifier(Modifier::BOLD).fg(WHITE))); | |
| 436 | + msgw.push(Span::styled( | |
| 437 | + "C", | |
| 438 | + Style::default().add_modifier(Modifier::BOLD).fg(WHITE), | |
| 439 | + )); | |
| 446 | 440 | } else { |
| 447 | − msgw.push(Span::styled("C", Style::default().add_modifier(Modifier::BOLD).fg(SLATE.c500))); | |
| 441 | + msgw.push(Span::styled( | |
| 442 | + "C", | |
| 443 | + Style::default().add_modifier(Modifier::BOLD).fg(SLATE.c500), | |
| 444 | + )); | |
| 448 | 445 | } |
| 449 | 446 | msgw.push(Span::raw("/")); |
| 450 | 447 | |
| 451 | 448 | if app.ppl_show_dates { |
| 452 | − msgw.push(Span::styled("D", Style::default().add_modifier(Modifier::BOLD).fg(WHITE))); | |
| 449 | + msgw.push(Span::styled( | |
| 450 | + "D", | |
| 451 | + Style::default().add_modifier(Modifier::BOLD).fg(WHITE), | |
| 452 | + )); | |
| 453 | 453 | } else { |
| 454 | − msgw.push(Span::styled("D", Style::default().add_modifier(Modifier::BOLD).fg(SLATE.c500))); | |
| 454 | + msgw.push(Span::styled( | |
| 455 | + "D", | |
| 456 | + Style::default().add_modifier(Modifier::BOLD).fg(SLATE.c500), | |
| 457 | + )); | |
| 455 | 458 | } |
| 456 | 459 | msgw.push(Span::raw("/")); |
| 457 | 460 | |
| 458 | 461 | if app.ppl_show_traits { |
| 459 | − msgw.push(Span::styled("R", Style::default().add_modifier(Modifier::BOLD).fg(WHITE))); | |
| 462 | + msgw.push(Span::styled( | |
| 463 | + "R", | |
| 464 | + Style::default().add_modifier(Modifier::BOLD).fg(WHITE), | |
| 465 | + )); | |
| 460 | 466 | } else { |
| 461 | − msgw.push(Span::styled("R", Style::default().add_modifier(Modifier::BOLD).fg(SLATE.c500))); | |
| 467 | + msgw.push(Span::styled( | |
| 468 | + "R", | |
| 469 | + Style::default().add_modifier(Modifier::BOLD).fg(SLATE.c500), | |
| 470 | + )); | |
| 462 | 471 | } |
| 463 | 472 | msgw.push(Span::raw("/")); |
| 464 | 473 | |
| 465 | 474 | if app.ppl_show_tiers { |
| 466 | − msgw.push(Span::styled("I", Style::default().add_modifier(Modifier::BOLD).fg(WHITE))); | |
| 475 | + msgw.push(Span::styled( | |
| 476 | + "I", | |
| 477 | + Style::default().add_modifier(Modifier::BOLD).fg(WHITE), | |
| 478 | + )); | |
| 467 | 479 | } else { |
| 468 | − msgw.push(Span::styled("I", Style::default().add_modifier(Modifier::BOLD).fg(SLATE.c500))); | |
| 480 | + msgw.push(Span::styled( | |
| 481 | + "I", | |
| 482 | + Style::default().add_modifier(Modifier::BOLD).fg(SLATE.c500), | |
| 483 | + )); | |
| 469 | 484 | } |
| 470 | 485 | msgw.push(Span::raw("/")); |
| 471 | 486 | |
| 472 | 487 | if app.ppl_show_relations { |
| 473 | − msgw.push(Span::styled("L", Style::default().add_modifier(Modifier::BOLD).fg(WHITE))); | |
| 488 | + msgw.push(Span::styled( | |
| 489 | + "L", | |
| 490 | + Style::default().add_modifier(Modifier::BOLD).fg(WHITE), | |
| 491 | + )); | |
| 474 | 492 | } else { |
| 475 | − msgw.push(Span::styled("L", Style::default().add_modifier(Modifier::BOLD).fg(SLATE.c500))); | |
| 493 | + msgw.push(Span::styled( | |
| 494 | + "L", | |
| 495 | + Style::default().add_modifier(Modifier::BOLD).fg(SLATE.c500), | |
| 496 | + )); | |
| 476 | 497 | } |
| 477 | 498 | |
| 478 | − | |
| 479 | − msgw.push(Span::raw(" to toggle Contacts/Dates/tRaits/tIers/reLations")); | |
| 499 | + msgw.push(Span::raw( | |
| 500 | + " to toggle Contacts/Dates/tRaits/tIers/reLations", | |
| 501 | + )); | |
| 480 | 502 | |
| 481 | 503 | let textw = Text::from(Line::from(msgw)).style(Style::default()); |
| 482 | 504 | let welcome = Paragraph::new(textw); |
@@ -726,7 +748,9 @@ fn render(f: &mut Frame, app: &mut Tui) {
| 726 | 748 | id: t.id, |
| 727 | 749 | tgt: Editablez::Contact, |
| 728 | 750 | first: t.r#type.clone(), |
| 729 | − second: Option::from(t.designator.clone().unwrap_or("".to_string())), | |
| 751 | + second: Option::from( | |
| 752 | + t.designator.clone().unwrap_or("".to_string()), | |
| 753 | + ), | |
| 730 | 754 | third: Option::from(t.value.clone()), |
| 731 | 755 | }); |
| 732 | 756 |
@@ -958,7 +982,8 @@ fn render(f: &mut Frame, app: &mut Tui) {
| 958 | 982 | .iter() |
| 959 | 983 | .map(|d| { |
| 960 | 984 | let mut n = d.clone(); |
| 961 | − n.date = NaiveDate::from_ymd_opt(start.year(), n.date.month(), n.date.day()).unwrap(); | |
| 985 | + n.date = NaiveDate::from_ymd_opt(start.year(), n.date.month(), n.date.day()) | |
| 986 | + .unwrap(); | |
| 962 | 987 | let p = app |
| 963 | 988 | .ppl_list |
| 964 | 989 | .iter() |
@@ -994,7 +1019,7 @@ fn render(f: &mut Frame, app: &mut Tui) {
| 994 | 1019 | Month::try_from(u.date.date.month() as u8).expect("oops"), |
| 995 | 1020 | u.date.date.day() as u8, |
| 996 | 1021 | ) |
| 997 | − .expect("doubleoops"), | |
| 1022 | + .expect("doubleoops"), | |
| 998 | 1023 | Style::default() |
| 999 | 1024 | .add_modifier(Modifier::BOLD) |
| 1000 | 1025 | .fg(GREEN.c300) |
@@ -1097,53 +1122,52 @@ struct SigDateAndProps {
| 1097 | 1122 | impl From<PplAndProps> for ListItem<'_> { |
| 1098 | 1123 | fn from(value: PplAndProps) -> Self { |
| 1099 | 1124 | // value.date_up; |
| 1100 | − let line = match value.ppl.me { | |
| 1101 | − true => Line::styled( | |
| 1102 | − format!(" 🌟 {}", value.ppl.nick.unwrap_or(value.ppl.name)), | |
| 1103 | − WHITE, | |
| 1104 | − ), | |
| 1105 | − false => match value.tiers.len() { | |
| 1106 | − 0 => Line::styled( | |
| 1107 | − format!(" {}", value.ppl.nick.unwrap_or(value.ppl.name)), | |
| 1125 | + let line = | |
| 1126 | + match value.ppl.me { | |
| 1127 | + true => Line::styled( | |
| 1128 | + format!(" 🌟 {}", value.ppl.nick.unwrap_or(value.ppl.name)), | |
| 1108 | 1129 | WHITE, |
| 1109 | 1130 | ), |
| 1110 | − _ => { | |
| 1111 | − let t = value.tiers.first().unwrap(); | |
| 1112 | − match value.tier_defaults.iter().find(|q| q.key == t.name) { | |
| 1113 | − None => Line::styled( | |
| 1114 | − format!(" {}", value.ppl.nick.unwrap_or(value.ppl.name)), | |
| 1115 | − WHITE, | |
| 1116 | − ), | |
| 1117 | − Some(tierd) => match t.symbol.clone().unwrap_or("".to_string()).as_str() { | |
| 1118 | − "" => Line::styled( | |
| 1119 | − format!( | |
| 1120 | − " {} {}", | |
| 1121 | − tierd.symbol.clone().unwrap_or("".to_string()), | |
| 1122 | − value.ppl.nick.unwrap_or(value.ppl.name) | |
| 1123 | − ), | |
| 1124 | − lcolor( | |
| 1125 | − &t.color | |
| 1126 | − .clone() | |
| 1127 | − .unwrap_or(tierd.color.clone().unwrap_or("".to_string())), | |
| 1128 | − ), | |
| 1129 | − ), | |
| 1130 | − otherwise => Line::styled( | |
| 1131 | − format!( | |
| 1132 | − " {} {}", | |
| 1133 | − otherwise, | |
| 1134 | − value.ppl.nick.unwrap_or(value.ppl.name) | |
| 1135 | − ), | |
| 1136 | − lcolor( | |
| 1137 | − &t.color | |
| 1138 | − .clone() | |
| 1139 | − .unwrap_or(tierd.color.clone().unwrap_or("".to_string())), | |
| 1140 | − ), | |
| 1131 | + false => match value.tiers.len() { | |
| 1132 | + 0 => Line::styled( | |
| 1133 | + format!(" {}", value.ppl.nick.unwrap_or(value.ppl.name)), | |
| 1134 | + WHITE, | |
| 1135 | + ), | |
| 1136 | + _ => { | |
| 1137 | + let t = value.tiers.first().unwrap(); | |
| 1138 | + match value.tier_defaults.iter().find(|q| q.key == t.name) { | |
| 1139 | + None => Line::styled( | |
| 1140 | + format!(" {}", value.ppl.nick.unwrap_or(value.ppl.name)), | |
| 1141 | + WHITE, | |
| 1141 | 1142 | ), |
| 1142 | − }, | |
| 1143 | + Some(tierd) => { | |
| 1144 | + match t.symbol.clone().unwrap_or("".to_string()).as_str() { | |
| 1145 | + "" => Line::styled( | |
| 1146 | + format!( | |
| 1147 | + " {} {}", | |
| 1148 | + tierd.symbol.clone().unwrap_or("".to_string()), | |
| 1149 | + value.ppl.nick.unwrap_or(value.ppl.name) | |
| 1150 | + ), | |
| 1151 | + lcolor(&t.color.clone().unwrap_or( | |
| 1152 | + tierd.color.clone().unwrap_or("".to_string()), | |
| 1153 | + )), | |
| 1154 | + ), | |
| 1155 | + otherwise => Line::styled( | |
| 1156 | + format!( | |
| 1157 | + " {} {}", | |
| 1158 | + otherwise, | |
| 1159 | + value.ppl.nick.unwrap_or(value.ppl.name) | |
| 1160 | + ), | |
| 1161 | + lcolor(&t.color.clone().unwrap_or( | |
| 1162 | + tierd.color.clone().unwrap_or("".to_string()), | |
| 1163 | + )), | |
| 1164 | + ), | |
| 1165 | + } | |
| 1166 | + } | |
| 1167 | + } | |
| 1143 | 1168 | } |
| 1144 | − } | |
| 1145 | − }, | |
| 1146 | − }; | |
| 1169 | + }, | |
| 1170 | + }; | |
| 1147 | 1171 | ListItem::new(line) |
| 1148 | 1172 | } |
| 1149 | 1173 | } |
@@ -1156,9 +1180,10 @@ impl From<&SigDateAndProps> for ListItem<'_> {
| 1156 | 1180 | .iter() |
| 1157 | 1181 | .find(|q| q.key == value.date.event && q.is_date == true); |
| 1158 | 1182 | let line = match (value.date.do_remind, default) { |
| 1159 | − (true, Some(t)) => { | |
| 1160 | − Line::styled(format!(" ✓ {} {:6} {}", t.symbol, n, value.date.date), WHITE) | |
| 1161 | − } | |
| 1183 | + (true, Some(t)) => Line::styled( | |
| 1184 | + format!(" ✓ {} {:6} {}", t.symbol, n, value.date.date), | |
| 1185 | + WHITE, | |
| 1186 | + ), | |
| 1162 | 1187 | (true, None) => Line::styled( |
| 1163 | 1188 | format!(" ✓ 📅 {:6} {} ({})", n, value.date.date, value.date.event), |
| 1164 | 1189 | WHITE, |
@@ -1192,7 +1217,10 @@ impl From<&ppl::Model> for ListItem<'_> {
| 1192 | 1217 | impl From<&tier_defaults::Model> for ListItem<'_> { |
| 1193 | 1218 | fn from(value: &tier_defaults::Model) -> Self { |
| 1194 | 1219 | let line = match value.enabled { |
| 1195 | − true => Line::styled(format!(" ✓ {:?} {}", value.symbol, value.key), lcolor(&value.color.clone().unwrap_or("".to_string()))), | |
| 1220 | + true => Line::styled( | |
| 1221 | + format!(" ✓ {:?} {}", value.symbol, value.key), | |
| 1222 | + lcolor(&value.color.clone().unwrap_or("".to_string())), | |
| 1223 | + ), | |
| 1196 | 1224 | false => Line::styled(format!(" ☐ {:?} {}", value.symbol, value.key), SLATE.c500), |
| 1197 | 1225 | }; |
| 1198 | 1226 |
@@ -1202,7 +1230,10 @@ impl From<&tier_defaults::Model> for ListItem<'_> {
| 1202 | 1230 | impl From<&trait_defaults::Model> for ListItem<'_> { |
| 1203 | 1231 | fn from(value: &trait_defaults::Model) -> Self { |
| 1204 | 1232 | let line = match value.enabled { |
| 1205 | − true => Line::styled(format!(" ✓ {} {}", value.symbol, value.key), lcolor(&value.color)), | |
| 1233 | + true => Line::styled( | |
| 1234 | + format!(" ✓ {} {}", value.symbol, value.key), | |
| 1235 | + lcolor(&value.color), | |
| 1236 | + ), | |
| 1206 | 1237 | false => Line::styled(format!(" ☐ {} {}", value.symbol, value.key), SLATE.c500), |
| 1207 | 1238 | }; |
| 1208 | 1239 |
Parents: 26fb8db