diff --git a/Cargo.lock b/Cargo.lock index f9bbc14..4fbc7de 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,151 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "anstyle" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "bitflags" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" +dependencies = [ + "serde", +] + +[[package]] +name = "clap" +version = "4.5.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6088f3ae8c3608d19260cd7445411865a485688711b78b5be70d78cd96136f83" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22a7ef7f676155edfb82daa97f99441f3ebf4a58d5e32f295a56259f1b6facc8" +dependencies = [ + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09176aae279615badda0765c0c0b3f6ed53f4709118af73cf4655d85d1530cd7" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "miller" version = "0.1.0" +dependencies = [ + "clap", + "ron", + "serde", +] + +[[package]] +name = "proc-macro2" +version = "1.0.94" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "ron" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63f3aa105dea217ef30d89581b65a4d527a19afc95ef5750be3890e8d3c5b837" +dependencies = [ + "base64", + "bitflags", + "serde", + "serde_derive", + "unicode-ident", +] + +[[package]] +name = "serde" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "syn" +version = "2.0.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" diff --git a/Cargo.toml b/Cargo.toml index 8edf65e..23318a1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,3 +4,24 @@ version = "0.1.0" edition = "2024" [dependencies] +ron = "~0.9" + +[dependencies.clap] +version = "4.5" +default-features = false +features = [ + # From default features collection + "error-context", + "help", + "std", + "suggestions", + "usage", + + # Optional features + "derive", + "string", +] + +[dependencies.serde] +version = "1.0" +features = ["derive"] diff --git a/src/calculator.rs b/src/calculator.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/gamelog.rs b/src/gamelog.rs new file mode 100644 index 0000000..52f07c6 --- /dev/null +++ b/src/gamelog.rs @@ -0,0 +1,100 @@ +use ron::de::{SpannedError, from_reader}; +use serde::Deserialize; +use std::{fmt, fs::File}; + +#[derive(Debug, Deserialize)] +pub struct LogFile(Vec); + +impl TryFrom for LogFile { + type Error = SpannedError; + + fn try_from(file: File) -> Result { + from_reader(file) + } +} + +#[derive(Debug, Deserialize)] +struct GameRecord([Option; 4]); + +#[derive(Debug, Deserialize)] +struct Period { + start: Quarter, + end: Option, + plays: Vec, +} + +#[derive(Debug, Deserialize)] +enum Quarter { + First, + Second, + Third, + Fourth, +} + +#[derive(Debug, Deserialize)] +struct Play { + action: Option, + down: Down, + terrain: u8, +} + +enum DownError { + NotKickoff, +} + +impl fmt::Display for DownError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match *self { + Self::NotKickoff => write!(f, "Variant was not Down::Kickoff."), + } + } +} + +#[derive(Debug, Deserialize)] +enum Down { + Kickoff { offence: Team }, + First, + Second, + Third, + Fourth, + Pat, +} + +impl Down { + fn get_offence(&self) -> Result<&Team, DownError> { + match self { + Self::Kickoff { offence } => Ok(offence), + _ => Err(DownError::NotKickoff), + } + } +} + +#[derive(Debug, Deserialize)] +enum Action { + CrackStudentBodyRightTackle, + Curls, + FleaFlicker, + HalfbackSlam, + HalfbackSlipScreen, + HalfbackSweep, + Mesh, + PlayActionBoot, + PlayActionComebacks, + PlayActionPowerZero, + PowerZero, + SlantBubble, + SlotOut, + SpeedOption, + StrongFlood, +} + +#[derive(Debug, Deserialize, Clone)] +enum Team { + ArizonaState, + Colorado, + Iowa, + Nebraska, + SouthCarolina, + Syracuse, + TexasAnM, +} diff --git a/src/main.rs b/src/main.rs index e7a11a9..11cb0bb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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"); } diff --git a/templates/logfile.ron b/templates/logfile.ron new file mode 100644 index 0000000..5a8a776 --- /dev/null +++ b/templates/logfile.ron @@ -0,0 +1,18 @@ +[ + GameRecord ([ + Some(Period( + start: First, + end: Some(Fourth), + plays: [ + Play( + action: None, + down: Kickoff, + terrain: 0 + ), + ] + )), + None, + None, + None, + ]) +] diff --git a/zed_settings.jsonc b/zed_settings.jsonc new file mode 100644 index 0000000..87efb86 --- /dev/null +++ b/zed_settings.jsonc @@ -0,0 +1,52 @@ +// Zed settings +// +// For information on how to configure Zed, see the Zed +// documentation: https://zed.dev/docs/configuring-zed +// +// To see all of Zed's default settings without changing your +// custom settings, run `zed: open default settings` from the +// command palette (cmd-shift-p / ctrl-shift-p) +{ + "telemetry": { + "diagnostics": true, + "metrics": false, + }, + "ui_font_size": 16, + "buffer_font_size": 13, + "icon_theme": "Colored Zed Icons Theme Dark", + "theme": { + "mode": "system", + "light": "One Light", + "dark": "One Dark", + }, + "restore_on_startup": "last_workspace", + "soft_wrap": "preferred_line_length", + + // Remove AI Crap + "features": { + "edit_prediction_provider": "none", + "copilot": false, + }, + "assistant": { + "version": "1", + "enabled": false, + }, + + // Language Overrides + "languages": { + "Python": { + "show_wrap_guides": true, + "preferred_line_length": 80, + }, + "Rust": { + "show_wrap_guides": true, + "preferred_line_length": 100, + }, + "JSON": { + "tab_size": 4, + }, + "JSONC": { + "tab_size": 4, + }, + }, +}