Building LogFile Format

This commit is contained in:
Cutieguwu
2025-03-24 21:58:41 -04:00
parent 483d31cc36
commit a0c587d222
7 changed files with 368 additions and 2 deletions

View File

@@ -1,3 +1,33 @@
fn main() {
println!("Hello, world!");
mod calculator;
mod gamelog;
use clap::Parser;
use gamelog::LogFile;
use std::{fs::OpenOptions, path::PathBuf};
#[derive(Debug, Parser)]
struct Args {
/// Path to source file or block device
#[arg(
short,
long,
value_hint = clap::ValueHint::DirPath,
default_value = std::env::current_dir().expect("Failed to get current working dir.").into_os_string()
)]
logfile_path: PathBuf,
}
fn main() {
let config = Args::parse();
let log: LogFile = LogFile::try_from(
match OpenOptions::new() // Defaults to setting all options false.
.read(true)
.open(&config.logfile_path.as_path())
{
Ok(f) => f,
Err(err) => panic!("Failed to open log file: {:?}", err),
},
)
.expect("Failed to open game log file");
}