From 7d0cd46debb59bfdbaeb55d10ce0305ddb04a6be Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Sat, 5 Jul 2025 23:20:08 -0700 Subject: [PATCH] Set file name using config name --- src/main.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 6339b42..7823083 100644 --- a/src/main.rs +++ b/src/main.rs @@ -98,13 +98,12 @@ struct Averages { temp: f64, } -//const OUT_FILE_NAME: &str = "hmm.svg"; -const OUT_FILE_NAME: &str = "hmm.png"; // TODO: Switch to SVG fn main() -> Result<(), Box> { // Parse data let args = Args::parse(); - let toml_data = fs::read_to_string(args.config.expect("Config not specified.")) - .expect("Failed to read data file."); + let config_path = args.config.expect("Config not specified."); + let out_path = config_path.with_extension("png"); + let toml_data = fs::read_to_string(&config_path).expect("Failed to read data file."); let data: Data = toml::from_str(&toml_data).expect("Failed to parse TOML data"); let max_temp = f64::ceil((data.max_temp() + 1.0) / 5.0) * 5.0; let min_temp = f64::floor((data.min_temp() - 1.0) / 5.0) * 5.0; @@ -112,8 +111,9 @@ fn main() -> Result<(), Box> { // Chart data let mut line_colors = LineColors::new(); - //let root = SVGBackend::new(OUT_FILE_NAME, (1600, 900)).into_drawing_area(); - let root = BitMapBackend::new(OUT_FILE_NAME, (1600, 900)).into_drawing_area(); + // TODO: Switch to SVG + // let root = SVGBackend::new(out_path, (1600, 900)).into_drawing_area(); + let root = BitMapBackend::new(&out_path, (1600, 900)).into_drawing_area(); root.fill(&WHITE)?;