From b50b82213775f655d00b55a21aa542c9f2696ac3 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Sun, 28 Jun 2020 17:41:18 +0200 Subject: add a small example as examples/loginfo.rs You can run it with cargo run --example=loginfo -- path/to/log --- examples/loginfo.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 examples/loginfo.rs diff --git a/examples/loginfo.rs b/examples/loginfo.rs new file mode 100644 index 0000000..8ad0093 --- /dev/null +++ b/examples/loginfo.rs @@ -0,0 +1,34 @@ +use std::{env, process}; + +use evtclib::Compression; + +fn main() { + let name = if let Some(name) = env::args().nth(1) { + name + } else { + eprintln!("Expected a file name"); + process::exit(1); + }; + + let compression = if name.ends_with(".zip") || name.ends_with(".zevtc") { + Compression::Zip + } else { + Compression::None + }; + + let log = evtclib::process_file(&name, compression).unwrap(); + + println!("Encounter: {:?}", log.encounter()); + println!("Was CM? {}", log.is_cm()); + println!("Players:"); + for player in log.players() { + println!( + "{} {} {}", + player.subgroup(), + player.account_name(), + player.character_name() + ); + } + + println!("Number of recorded events: {}", log.events().len()); +} -- cgit v1.2.3