Fix formatting and LogFile loading.

This commit is contained in:
Cutieguwu
2025-03-26 20:53:41 -04:00
parent 3f7d51150c
commit 94704a5558

View File

@@ -1,9 +1,10 @@
mod calculator;
mod error;
mod gamelog;
use clap::Parser;
use core::panic;
use gamelog::{GAMELOG_MIN_VER, LogFile};
use gamelog::LogFile;
use std::path::PathBuf;
#[derive(Debug, Parser)]
@@ -13,9 +14,11 @@ struct Args {
short,
long,
value_hint = clap::ValueHint::DirPath,
default_value = dbg!(format!("{}/templates/logfile.ron", std::env::current_dir()
default_value = format!("{}/templates/logfile.ron", std::env::current_dir()
.expect("Failed to get current working dir.")
.into_os_string().to_str().unwrap()))
.into_os_string()
.to_str()
.unwrap())
)]
logfile_path: PathBuf,
}
@@ -23,14 +26,14 @@ struct Args {
fn main() {
let config = Args::parse();
let mut log: LogFile = {
let log: LogFile = {
let file = match LogFile::try_from(config.logfile_path) {
Ok(f) => f,
Err(err) => panic!("Error: Failed to open logfile: {:?}", err),
};
match file.ensure_compatible() {
Ok(f) => f.try_into().expect(msg),
Ok(f) => f,
Err(err) => panic!("Error: Failed to ensure logfile compatibility: {:?}", err),
}
};