Skip to content

Commit

Permalink
Wait for user to close or press key, write to output.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
RealMrCactus committed Nov 16, 2023
1 parent dc5ba94 commit d6dec9d
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ extern crate regex;
use regex::Regex;
use std::fs;
use std::collections::HashSet;

use std::fs::File;
use std::io::prelude::*;

fn main() {
let app_data_path = std::env::var("APPDATA").expect("APPDATA not found");
Expand All @@ -21,18 +22,23 @@ fn main() {

// Find all matches and process them
let mut found_any = false;
let mut output = String::new();

for cap in re.captures_iter(&text) {
let id = cap[1].to_string();
let name = cap[2].to_string();
let team = cap[3].to_string();

if seen.insert((id.clone(), name.clone(), team.clone())) {
found_any = true;
println!("ID: {}, Name: {}, Team: {}", id, name, team);
output.push_str(&format!("ID: {}, Name: {}, Team: {}\n", id, name, team));
}
}

if !found_any {
println!("No player data found in the log.");
output.push_str("No player data found in the log.\n");
}
fs::write("output.txt", output.clone()).expect("Unable to write to file");
println!("{}", output);
std::io::stdin().read_line(&mut String::new()).unwrap();
}

0 comments on commit d6dec9d

Please sign in to comment.