Fix formatting and LogFile loading.
This commit is contained in:
13
src/main.rs
13
src/main.rs
@@ -1,9 +1,10 @@
|
|||||||
mod calculator;
|
mod calculator;
|
||||||
|
mod error;
|
||||||
mod gamelog;
|
mod gamelog;
|
||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use core::panic;
|
use core::panic;
|
||||||
use gamelog::{GAMELOG_MIN_VER, LogFile};
|
use gamelog::LogFile;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
@@ -13,9 +14,11 @@ struct Args {
|
|||||||
short,
|
short,
|
||||||
long,
|
long,
|
||||||
value_hint = clap::ValueHint::DirPath,
|
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.")
|
.expect("Failed to get current working dir.")
|
||||||
.into_os_string().to_str().unwrap()))
|
.into_os_string()
|
||||||
|
.to_str()
|
||||||
|
.unwrap())
|
||||||
)]
|
)]
|
||||||
logfile_path: PathBuf,
|
logfile_path: PathBuf,
|
||||||
}
|
}
|
||||||
@@ -23,14 +26,14 @@ struct Args {
|
|||||||
fn main() {
|
fn main() {
|
||||||
let config = Args::parse();
|
let config = Args::parse();
|
||||||
|
|
||||||
let mut log: LogFile = {
|
let log: LogFile = {
|
||||||
let file = match LogFile::try_from(config.logfile_path) {
|
let file = match LogFile::try_from(config.logfile_path) {
|
||||||
Ok(f) => f,
|
Ok(f) => f,
|
||||||
Err(err) => panic!("Error: Failed to open logfile: {:?}", err),
|
Err(err) => panic!("Error: Failed to open logfile: {:?}", err),
|
||||||
};
|
};
|
||||||
|
|
||||||
match file.ensure_compatible() {
|
match file.ensure_compatible() {
|
||||||
Ok(f) => f.try_into().expect(msg),
|
Ok(f) => f,
|
||||||
Err(err) => panic!("Error: Failed to ensure logfile compatibility: {:?}", err),
|
Err(err) => panic!("Error: Failed to ensure logfile compatibility: {:?}", err),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user