Add ability to run multiple days from command line

Also add timing for the entire program run.
This commit is contained in:
2022-12-16 08:42:13 -06:00
parent fdf621b58d
commit fcfdb7146b

View File

@ -1,5 +1,6 @@
using aoc2022;
using aoc2022.Timer t = new("Full program");
var types = System.Reflection.Assembly
.GetExecutingAssembly()
.GetTypes()
@ -9,7 +10,7 @@ var types = System.Reflection.Assembly
bool runAll = false;
bool? runPart1 = null;
bool? runPart2 = null;
string? desiredDay = null;
List<string> desiredDays = new();
foreach (var arg in args)
{
if (arg.Equals("-part1", StringComparison.CurrentCultureIgnoreCase))
@ -26,7 +27,7 @@ foreach (var arg in args)
}
else
{
desiredDay = arg;
desiredDays.Add(arg);
}
}
@ -45,6 +46,13 @@ if (runAll)
}
}
else
{
if (desiredDays.Count == 0)
{
desiredDays.Add("");
}
foreach (var desiredDay in desiredDays)
{
Day? day = null;
if (string.IsNullOrEmpty(desiredDay))
@ -63,6 +71,8 @@ else
day = (Day?) Activator.CreateInstance(type);
}
}
day?.Go(runPart1 ?? true, runPart2 ?? true);
day?.Dispose();
}
}