From f791675d3a5f9c734253fffcc9384460b9301739 Mon Sep 17 00:00:00 2001 From: Cutieguwu Date: Tue, 25 Mar 2025 12:14:24 -0400 Subject: [PATCH] Finish LogFile format and patch template/logfile.ron --- Cargo.lock | 10 ++++++++++ Cargo.toml | 6 +++++- src/gamelog.rs | 7 +++++-- src/main.rs | 4 +++- templates/logfile.ron | 38 ++++++++++++++++++++++---------------- 5 files changed, 45 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4fbc7de..81f6e96 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -74,6 +74,7 @@ version = "0.1.0" dependencies = [ "clap", "ron", + "semver", "serde", ] @@ -108,6 +109,15 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "semver" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0" +dependencies = [ + "serde", +] + [[package]] name = "serde" version = "1.0.219" diff --git a/Cargo.toml b/Cargo.toml index 23318a1..9d8f6bf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,11 @@ version = "0.1.0" edition = "2024" [dependencies] -ron = "~0.9" +ron = "0.9" + +[dependencies.semver] +version = "1.0" +features = ["serde"] [dependencies.clap] version = "4.5" diff --git a/src/gamelog.rs b/src/gamelog.rs index 52f07c6..6b70da7 100644 --- a/src/gamelog.rs +++ b/src/gamelog.rs @@ -14,7 +14,10 @@ impl TryFrom for LogFile { } #[derive(Debug, Deserialize)] -struct GameRecord([Option; 4]); +struct GameRecord { + version: semver::Version, + periods: Vec>, +} #[derive(Debug, Deserialize)] struct Period { @@ -57,7 +60,7 @@ enum Down { Second, Third, Fourth, - Pat, + PointAfterTouchdown, } impl Down { diff --git a/src/main.rs b/src/main.rs index 11cb0bb..fec82e1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,7 +12,9 @@ struct Args { short, long, value_hint = clap::ValueHint::DirPath, - default_value = std::env::current_dir().expect("Failed to get current working dir.").into_os_string() + default_value = std::env::current_dir() + .expect("Failed to get current working dir.") + .into_os_string() )] logfile_path: PathBuf, } diff --git a/templates/logfile.ron b/templates/logfile.ron index 5a8a776..0b52b93 100644 --- a/templates/logfile.ron +++ b/templates/logfile.ron @@ -1,18 +1,24 @@ +#![enable(implicit_some)] +#![enable(unwrap_newtypes)] +#![enable(unwrap_variant_newtypes)] + [ - GameRecord ([ - Some(Period( - start: First, - end: Some(Fourth), - plays: [ - Play( - action: None, - down: Kickoff, - terrain: 0 - ), - ] - )), - None, - None, - None, - ]) + GameRecord( + version: "0.0.1", + periods: [ + Period( + start: First, + end: Fourth, + plays: [ + Play( + action: None, + down: Kickoff( + offence: Nebraska + ), + terrain: 0 + ), + ] + ) + ] + ) ]