mirror of
https://codeberg.org/icewind/tf-log-parser.git
synced 2026-06-03 18:24:09 +02:00
add example that parses all
This commit is contained in:
parent
10293b7e5a
commit
9ad8a1fd9f
1 changed files with 20 additions and 0 deletions
20
examples/all.rs
Normal file
20
examples/all.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
use main_error::MainError;
|
||||||
|
use std::env::args;
|
||||||
|
use std::fs;
|
||||||
|
use tf_log_parser::{GameEvent, RawEvent};
|
||||||
|
|
||||||
|
fn main() -> Result<(), MainError> {
|
||||||
|
let path = args().nth(1).expect("No path provided");
|
||||||
|
let input = fs::read_to_string(path)?;
|
||||||
|
|
||||||
|
let events: Vec<_> = input
|
||||||
|
.split("L ")
|
||||||
|
.filter(|line| !line.is_empty())
|
||||||
|
.flat_map(RawEvent::parse)
|
||||||
|
.flat_map(|raw| GameEvent::parse(&raw))
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
println!("{} events parsed", events.len());
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue