From 846721067044f876b4ca3491992e77ec61a24fb8 Mon Sep 17 00:00:00 2001 From: Matt Hammerly Date: Thu, 25 Apr 2024 11:30:07 -0700 Subject: [PATCH] add cargo example / util to parse a given pyreport into sqlite --- examples/parse_pyreport.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 examples/parse_pyreport.rs diff --git a/examples/parse_pyreport.rs b/examples/parse_pyreport.rs new file mode 100644 index 0000000..6c2d28a --- /dev/null +++ b/examples/parse_pyreport.rs @@ -0,0 +1,27 @@ +use std::{env, fs::File, path::PathBuf}; + +use codecov_rs::parsers::pyreport_shim::parse_pyreport; + +fn usage_error() -> ! { + println!("Usage:"); + println!(" cargo run --example parse_pyreport -- [REPORT_JSON_PATH] [CHUNKS_PATH] [OUT_PATH]"); + + std::process::exit(1); +} + +pub fn main() -> Result<(), std::io::Error> { + let args: Vec = env::args().collect(); + + if args.len() != 4 { + usage_error(); + } + + + let report_json_file = File::open(&args[1])?; + let chunks_file = File::open(&args[2])?; + let out_path = PathBuf::from(&args[3]); + + parse_pyreport(&report_json_file, &chunks_file, out_path)?; + + Ok(()) +}