Finish LogFile format and patch template/logfile.ron

This commit is contained in:
Cutieguwu
2025-03-25 12:14:24 -04:00
parent aec577e93b
commit f791675d3a
5 changed files with 45 additions and 20 deletions

10
Cargo.lock generated
View File

@@ -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"

View File

@@ -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"

View File

@@ -14,7 +14,10 @@ impl TryFrom<File> for LogFile {
}
#[derive(Debug, Deserialize)]
struct GameRecord([Option<Period>; 4]);
struct GameRecord {
version: semver::Version,
periods: Vec<Option<Period>>,
}
#[derive(Debug, Deserialize)]
struct Period {
@@ -57,7 +60,7 @@ enum Down {
Second,
Third,
Fourth,
Pat,
PointAfterTouchdown,
}
impl Down {

View File

@@ -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,
}

View File

@@ -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
),
]
)
]
)
]