mirror of
https://codeberg.org/demostf/parser.git
synced 2026-06-03 18:24:05 +02:00
add cli option to parse all messages for easier debugging
This commit is contained in:
parent
baad66bc0c
commit
e6e32b292b
5 changed files with 57 additions and 16 deletions
|
|
@ -3,8 +3,6 @@ use std::fs;
|
|||
|
||||
pub use tf_demo_parser::{Demo, DemoParser, Parse, ParseError, ParserState, Result, Stream};
|
||||
|
||||
extern crate jemallocator;
|
||||
|
||||
#[global_allocator]
|
||||
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
|
||||
|
||||
|
|
@ -17,9 +15,17 @@ fn main() -> std::result::Result<(), Box<ParseError>> {
|
|||
return Ok(());
|
||||
}
|
||||
let path = args[1].clone();
|
||||
let all = args
|
||||
.get(2)
|
||||
.map(|arg| arg.as_str() == "all")
|
||||
.unwrap_or_default();
|
||||
let file = fs::read(path).expect("Unable to read file");
|
||||
let demo = Demo::new(file);
|
||||
let (_, state) = DemoParser::parse_demo(demo.get_stream())?;
|
||||
let (_, state) = if all {
|
||||
DemoParser::parse_all(demo.get_stream())
|
||||
} else {
|
||||
DemoParser::parse_demo(demo.get_stream())
|
||||
}?;
|
||||
let json = serde_json::to_string(&state).unwrap_or("err".to_string());
|
||||
println!("{}", json);
|
||||
Ok(())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue