chore(*): Add day creation tool

This commit is contained in:
Josh Creek
2022-10-13 09:25:24 +01:00
parent 75671d13e1
commit e2a3f2417a
5 changed files with 101 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
using System.Collections.Generic;
using System;
using System.IO;
using System.Text;
Console.Write("Year: ");
var year = Console.ReadLine();
Console.Write("Day: ");
var day = Console.ReadLine().PadLeft(2, '0'); ;
var currentLocation = System.Reflection.Assembly.GetExecutingAssembly().Location;
int ix = currentLocation.IndexOf("DayCreator");
var newPathBase = currentLocation.Substring(0, ix - 1);
string yearPath = Path.GetFullPath(Path.Combine(newPathBase, $@"AOC.Tests\Y{year}\"));
string dataPath = Path.GetFullPath(Path.Combine(yearPath, $@"Data\"));
string tasksPath = Path.GetFullPath(Path.Combine(yearPath, $@"Tasks\"));
// Create data file
using (FileStream fs = File.Create($"{dataPath}Day{day}.dat"));
// Create task file
using (FileStream fs = File.Create($"{tasksPath}Day{day}.txt"));
// Create code file
string text = File.ReadAllText("DayX.cs");
text = text.Replace("YX", $"Y{year}");
text = text.Replace("DayX", $"Day{day}");
File.WriteAllText($"{yearPath}Day{day}.cs", text);