Set file name using config name

This commit is contained in:
2Shirt 2025-07-05 23:20:08 -07:00
parent 528c4757a8
commit 7d0cd46deb
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C

View file

@ -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<dyn Error>> {
// 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<dyn Error>> {
// 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)?;