cache stdout handle

This commit is contained in:
Erik Zscheile 2019-12-23 02:37:18 +01:00
parent 64e877d4a6
commit 83b93866f2
4 changed files with 18 additions and 4 deletions

2
.gitignore vendored
View file

@ -1 +1,3 @@
/target
/flamegraph.svg
/perf.data*

1
Cargo.lock generated
View file

@ -413,6 +413,7 @@ dependencies = [
"prettytable-rs",
"readfilez",
"string_cache",
"term",
"thiserror",
]

View file

@ -13,3 +13,7 @@ readfilez = "0.2"
string_cache = "0.8"
thiserror = "1.0"
prettytable = { version = "0.8", package = "prettytable-rs" }
term = "0.5"
[profile.release]
lto = true

View file

@ -13,7 +13,10 @@ fn main() {
use chrono::Datelike;
use encoding::types::Encoding;
use prettytable::{cell, format, row, Table};
use std::collections::{BTreeMap, HashSet};
use std::{
collections::{BTreeMap, HashSet},
io::Write,
};
let mut highlight = HashSet::new();
@ -26,8 +29,10 @@ fn main() {
highlight.remove(";");
}
let mut stdout = term::stdout().unwrap();
for i in args {
println!("F = {}", i);
writeln!(&mut stdout, "F = {}", i).unwrap();
let fh = readfilez::read_from_file(std::fs::File::open(i)).expect("unable to open file");
@ -107,7 +112,7 @@ fn main() {
ent.1 += i.umsatz;
}
println!("skipped {} entries", i_skipped);
writeln!(&mut stdout, "skipped {} entries", i_skipped).unwrap();
if accu.is_empty() {
continue;
@ -152,6 +157,8 @@ fn main() {
});
}
table.printstd();
table
.print_term(&mut *stdout)
.expect("unable to print table");
}
}