+option '--highlight-only'
This commit is contained in:
parent
35541de631
commit
cbd0ab82bd
1 changed files with 20 additions and 16 deletions
36
src/main.rs
36
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::<String>::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::<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
|
||||
|
|
Loading…
Reference in a new issue