aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2020-06-28 17:41:18 +0200
committerDaniel Schadt <kingdread@gmx.de>2020-06-28 17:41:18 +0200
commitb50b82213775f655d00b55a21aa542c9f2696ac3 (patch)
treec069013b8b97deed99ac0cd36e2ec2d7922153cb
parentacdc4d977e573d54c73530f77ba210efd2184cf0 (diff)
downloadevtclib-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
-rw-r--r--examples/loginfo.rs34
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());
+}