aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md6
-rw-r--r--examples/loginfo.rs34
2 files changed, 40 insertions, 0 deletions
diff --git a/README.md b/README.md
index babfd3d..2f7e4ab 100644
--- a/README.md
+++ b/README.md
@@ -36,6 +36,12 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
}
```
+You can also check out `examples/loginfo.rs` or run it on a log file:
+
+```
+cargo run --example=loginfo -- path/to/log.zevtc
+```
+
License
-------
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());
+}