+option '--highlight-only'
This commit is contained in:
parent
35541de631
commit
cbd0ab82bd
1 changed files with 20 additions and 16 deletions
12
src/main.rs
12
src/main.rs
|
@ -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,23 +167,26 @@ 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);
|
||||||
|
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);
|
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) {
|
if is_ny.unwrap_or(false) {
|
||||||
table.add_row(row!["", "", "", ""]);
|
table.add_row(row!["", "", "", ""]);
|
||||||
}
|
}
|
||||||
v.2 += &std::iter::repeat(' ').take(pdsp - v.3).collect::<String>();
|
|
||||||
if is_ny.unwrap_or(true) {
|
if is_ny.unwrap_or(true) {
|
||||||
prev_yuhj = Some(yearuhj.clone());
|
prev_yuhj = Some(yearuhj.clone());
|
||||||
} else {
|
} else {
|
||||||
yearuhj.clear();
|
yearuhj.clear();
|
||||||
}
|
}
|
||||||
table.add_row(if highlight.contains(&*k.2) {
|
table.add_row(if !hl_only && is_hl {
|
||||||
row![yearuhj, FYBdb-> k.2, r-> v.0.to_string(), Fgbr-> v.2]
|
row![yearuhj, FYBdb-> k.2, r-> v.0.to_string(), Fgbr-> v.2]
|
||||||
} else {
|
} else {
|
||||||
row![yearuhj, k.2, r-> v.0.to_string(), r-> v.2]
|
row![yearuhj, k.2, r-> v.0.to_string(), r-> v.2]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
table
|
table
|
||||||
.print_term(&mut *stdout)
|
.print_term(&mut *stdout)
|
||||||
|
|
Loading…
Reference in a new issue