Format y2015d15 and add check to prevent overriding days...

This commit is contained in:
2024-11-04 11:32:48 +01:00
parent 9438245d84
commit 0d2fd4b451
7 changed files with 157 additions and 7 deletions

View File

@@ -47,6 +47,9 @@ fn prepare_year(year: &str) -> Result<(), std::io::Error> {
fn prepare_day(year: &str, day: &str) -> Result<(), std::io::Error> {
let root = env!("CARGO_MANIFEST_DIR");
if Path::new(&format!("{root}/y{year}/src/bin/d{day}.rs")).exists() {
panic!("Day y{year}d{day} already exists")
}
let bin = fs::read_to_string(format!("{root}/template/bin/d.rs.tmpl"))?
.replace("{{YEAR}}", year)
.replace("{{DAY}}", day);