diff options
author | Daniel Schadt <kingdread@gmx.de> | 2020-06-28 17:41:18 +0200 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2020-06-28 17:41:18 +0200 |
commit | b50b82213775f655d00b55a21aa542c9f2696ac3 (patch) | |
tree | c069013b8b97deed99ac0cd36e2ec2d7922153cb /examples | |
parent | acdc4d977e573d54c73530f77ba210efd2184cf0 (diff) | |
download | evtclib-b50b82213775f655d00b55a21aa542c9f2696ac3.tar.gz evtclib-b50b82213775f655d00b55a21aa542c9f2696ac3.tar.bz2 evtclib-b50b82213775f655d00b55a21aa542c9f2696ac3.zip |
add a small example as examples/loginfo.rs
You can run it with
cargo run --example=loginfo -- path/to/log
Diffstat (limited to 'examples')
-rw-r--r-- | examples/loginfo.rs | 34 |
1 files changed, 34 insertions, 0 deletions
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()); +} |