diff --git a/cli/src/main.rs b/cli/src/main.rs index 4bce3d43..afbe39e2 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -236,13 +236,15 @@ fn run() -> error::Result<()> { let mut has_error = false; loader.find_all_languages(&config.parser_directories)?; + let should_track_stats = matches.is_present("stat"); let mut stats : parse::Stats = Default::default(); for path in paths { let path = Path::new(&path); let language = select_language(&mut loader, path, ¤t_dir, matches.value_of("scope"))?; - has_error |= parse::parse_file_at_path( + + let this_file_errored = parse::parse_file_at_path( language, path, &edits, @@ -253,11 +255,19 @@ fn run() -> error::Result<()> { debug, debug_graph, allow_cancellation, - &mut stats, )?; + + if should_track_stats { + stats.total_parses += 1; + if !this_file_errored { + stats.successful_parses += 1; + } + } + + has_error |= this_file_errored; } - if matches.is_present("stat") { + if should_track_stats { println!("{}", stats) } diff --git a/cli/src/parse.rs b/cli/src/parse.rs index 53ad859e..568b2c52 100644 --- a/cli/src/parse.rs +++ b/cli/src/parse.rs @@ -16,8 +16,8 @@ pub struct Edit { #[derive(Debug, Default)] pub struct Stats { - successful_parses : usize, - total_parses : usize, + pub successful_parses : usize, + pub total_parses : usize, } impl fmt::Display for Stats { @@ -41,7 +41,6 @@ pub fn parse_file_at_path( debug: bool, debug_graph: bool, allow_cancellation: bool, - stats: &mut Stats, ) -> Result { let mut _log_session = None; let mut parser = Parser::new(); @@ -178,11 +177,6 @@ pub fn parse_file_at_path( } } - stats.total_parses += 1; - if first_error.is_none() { - stats.successful_parses += 1; - } - if first_error.is_some() || print_time { write!( &mut stdout,