diff --git a/src/main.rs b/src/main.rs index adaea8d..25931fb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,8 +23,9 @@ fn main() { }; let mut highlight = HashSet::new(); + let hl_only = args[0] == "--highlight-only"; - if args[0] == "--highlight" { + if args[0] == "--highlight" || hl_only { args.remove(0); let eo_selst = args.iter().take_while(|i| *i != ";").count(); highlight = args @@ -166,22 +167,25 @@ fn main() { let mut prev_yuhj = Option::::None; for (k, v) in accu.iter_mut() { - let mut yearuhj = format!("{} {}", k.0, if k.1 { "II" } else { "I" }); - let is_ny = prev_yuhj.as_ref().map(|i| i != &yearuhj); - if is_ny.unwrap_or(false) { - table.add_row(row!["", "", "", ""]); + let is_hl = highlight.contains(&*k.2); + if !hl_only || is_hl { + let mut yearuhj = format!("{} {}I", k.0, if k.1 { "I" } else { "" }); + let is_ny = prev_yuhj.as_ref().map(|i| i != &yearuhj); + v.2 += &std::iter::repeat(' ').take(pdsp - v.3).collect::(); + if is_ny.unwrap_or(false) { + table.add_row(row!["", "", "", ""]); + } + if is_ny.unwrap_or(true) { + prev_yuhj = Some(yearuhj.clone()); + } else { + yearuhj.clear(); + } + table.add_row(if !hl_only && is_hl { + row![yearuhj, FYBdb-> k.2, r-> v.0.to_string(), Fgbr-> v.2] + } else { + row![yearuhj, k.2, r-> v.0.to_string(), r-> v.2] + }); } - v.2 += &std::iter::repeat(' ').take(pdsp - v.3).collect::(); - if is_ny.unwrap_or(true) { - prev_yuhj = Some(yearuhj.clone()); - } else { - yearuhj.clear(); - } - table.add_row(if highlight.contains(&*k.2) { - row![yearuhj, FYBdb-> k.2, r-> v.0.to_string(), Fgbr-> v.2] - } else { - row![yearuhj, k.2, r-> v.0.to_string(), r-> v.2] - }); } table