Add support for recording "TerrainState::In" and GameRecord version support system.
This commit is contained in:
18
src/main.rs
18
src/main.rs
@@ -2,7 +2,7 @@ mod calculator;
|
||||
mod gamelog;
|
||||
|
||||
use clap::Parser;
|
||||
use gamelog::LogFile;
|
||||
use gamelog::{GAMELOG_MIN_VER, LogFile};
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
@@ -12,9 +12,9 @@ struct Args {
|
||||
short,
|
||||
long,
|
||||
value_hint = clap::ValueHint::DirPath,
|
||||
default_value = std::env::current_dir()
|
||||
default_value = dbg!(format!("{}/templates/logfile.ron", std::env::current_dir()
|
||||
.expect("Failed to get current working dir.")
|
||||
.into_os_string()
|
||||
.into_os_string().to_str().unwrap()))
|
||||
)]
|
||||
logfile_path: PathBuf,
|
||||
}
|
||||
@@ -22,7 +22,7 @@ struct Args {
|
||||
fn main() {
|
||||
let config = Args::parse();
|
||||
|
||||
let log: LogFile = LogFile::try_from(
|
||||
let mut log: LogFile = LogFile::try_from(
|
||||
match std::fs::OpenOptions::new() // Defaults to setting all options false.
|
||||
.read(true) // Only need ensure that reading is possible.
|
||||
.open(&config.logfile_path.as_path())
|
||||
@@ -32,4 +32,14 @@ fn main() {
|
||||
},
|
||||
)
|
||||
.expect("Failed to open game log file");
|
||||
|
||||
let log_ver = dbg!(log.get_min_ver());
|
||||
|
||||
if log_ver.cmp_precedence(&GAMELOG_MIN_VER).is_lt() {
|
||||
panic!(
|
||||
"Error: Log file GameRecord version deviates as low as {:?}, while minimum {:?} is required",
|
||||
log_ver.to_string(),
|
||||
GAMELOG_MIN_VER.to_string()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user