+option '--highlight-only'

This commit is contained in:
Erik Zscheile 2019-12-23 22:01:53 +01:00
parent 35541de631
commit cbd0ab82bd

View file

@ -23,8 +23,9 @@ fn main() {
}; };
let mut highlight = HashSet::new(); 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); args.remove(0);
let eo_selst = args.iter().take_while(|i| *i != ";").count(); let eo_selst = args.iter().take_while(|i| *i != ";").count();
highlight = args highlight = args
@ -166,22 +167,25 @@ fn main() {
let mut prev_yuhj = Option::<String>::None; let mut prev_yuhj = Option::<String>::None;
for (k, v) in accu.iter_mut() { for (k, v) in accu.iter_mut() {
let mut yearuhj = format!("{} {}", k.0, if k.1 { "II" } else { "I" }); let is_hl = highlight.contains(&*k.2);
let is_ny = prev_yuhj.as_ref().map(|i| i != &yearuhj); if !hl_only || is_hl {
if is_ny.unwrap_or(false) { let mut yearuhj = format!("{} {}I", k.0, if k.1 { "I" } else { "" });
table.add_row(row!["", "", "", ""]); let is_ny = prev_yuhj.as_ref().map(|i| i != &yearuhj);
v.2 += &std::iter::repeat(' ').take(pdsp - v.3).collect::<String>();
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::<String>();
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 table