mirror of
https://codeberg.org/demostf/parser.git
synced 2026-06-03 10:14:06 +02:00
take path from argument
This commit is contained in:
parent
f07770f206
commit
0b331c83e2
1 changed files with 7 additions and 4 deletions
|
|
@ -1,18 +1,21 @@
|
|||
#[allow(unused_variables)]
|
||||
use std::error::Error;
|
||||
use std::fs;
|
||||
use std::env;
|
||||
|
||||
pub use tf_demo_parser::{Demo, DemoParser, Parse, ParseError, ParserState, Result, Stream};
|
||||
|
||||
fn main() -> std::result::Result<(), Box<ParseError>> {
|
||||
let file = fs::read("data/ash.dem").expect("Unable to read file");
|
||||
let args: Vec<_> = env::args().collect();
|
||||
if args.len() < 2{
|
||||
panic!("1 argument required");
|
||||
}
|
||||
let path = args[1].clone();
|
||||
let file = fs::read(path).expect("Unable to read file");
|
||||
let demo = Demo::new(file);
|
||||
let stream: Stream = demo.get_stream();
|
||||
let mut parser = DemoParser::new(stream);
|
||||
let (header, state) = parser.parse_demo()?;
|
||||
//dbg!(header);
|
||||
//dbg!(state.deaths);
|
||||
//std::thread::sleep(std::time::Duration::from_secs(5));
|
||||
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