Add --stats flag for reporting parse information.

This commit is contained in:
Patrick Thomson 2020-09-29 12:34:25 -04:00
parent 5080de496a
commit 939cdf12b9
2 changed files with 33 additions and 1 deletions

View file

@ -64,6 +64,7 @@ fn run() -> error::Result<()> {
.arg(Arg::with_name("debug").long("debug").short("d"))
.arg(Arg::with_name("debug-graph").long("debug-graph").short("D"))
.arg(Arg::with_name("quiet").long("quiet").short("q"))
.arg(Arg::with_name("stat").long("stat").short("s"))
.arg(Arg::with_name("time").long("time").short("t"))
.arg(Arg::with_name("allow-cancellation").long("cancel"))
.arg(Arg::with_name("timeout").long("timeout").takes_value(true))
@ -234,6 +235,9 @@ fn run() -> error::Result<()> {
let max_path_length = paths.iter().map(|p| p.chars().count()).max().unwrap();
let mut has_error = false;
loader.find_all_languages(&config.parser_directories)?;
let mut stats : parse::Stats = Default::default();
for path in paths {
let path = Path::new(&path);
let language =
@ -249,8 +253,14 @@ fn run() -> error::Result<()> {
debug,
debug_graph,
allow_cancellation,
&mut stats,
)?;
}
if matches.is_present("stat") {
println!("{}", stats)
}
if has_error {
return Error::err(String::new());
}