Add day selector
This commit is contained in:
18
Program.cs
Normal file
18
Program.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
|
||||
using System.Reflection;
|
||||
using AdventOfCode.Days;
|
||||
using Spectre.Console;
|
||||
|
||||
var days = Assembly.GetAssembly(typeof(Day))!.GetTypes()
|
||||
.Where(t => t.IsAssignableTo(typeof(Day)) && t.GetConstructor(Type.EmptyTypes) != null && !t.IsAbstract)
|
||||
.Select(t => (Day)Activator.CreateInstance(t)!);
|
||||
|
||||
var select = new SelectionPrompt<Day>()
|
||||
.Title("[cyan]Select a [yellow]day[/] to run:[/]")
|
||||
.AddChoices(days);
|
||||
|
||||
var selectedDay = AnsiConsole.Prompt(select);
|
||||
|
||||
AnsiConsole.MarkupLine($"[cyan]Running [yellow]{selectedDay}[/]...[/]\n");
|
||||
|
||||
selectedDay.Run();
|
||||
Reference in New Issue
Block a user