using System.CommandLine; using NatsNet.PortTracker.Commands; using NatsNet.PortTracker.Data; var dbOption = new Option("--db") { Description = "Path to the SQLite database file", DefaultValueFactory = _ => Path.Combine(Directory.GetCurrentDirectory(), "porting.db"), Recursive = true }; var schemaOption = new Option("--schema") { Description = "Path to the SQL schema file", DefaultValueFactory = _ => Path.Combine(Directory.GetCurrentDirectory(), "porting-schema.sql"), Recursive = true }; var rootCommand = new RootCommand("NATS .NET Porting Tracker"); rootCommand.Add(dbOption); rootCommand.Add(schemaOption); // init command var initCommand = new Command("init", "Create or reset the database schema"); initCommand.SetAction(parseResult => { var dbPath = parseResult.GetValue(dbOption)!; var schemaPath = parseResult.GetValue(schemaOption)!; using var db = new Database(dbPath); Schema.Initialize(db, schemaPath); Console.WriteLine($"Database initialized at {dbPath}"); }); rootCommand.Add(initCommand); rootCommand.Add(ModuleCommands.Create(dbOption, schemaOption)); rootCommand.Add(FeatureCommands.Create(dbOption, schemaOption)); rootCommand.Add(TestCommands.Create(dbOption, schemaOption)); rootCommand.Add(LibraryCommands.Create(dbOption, schemaOption)); rootCommand.Add(DependencyCommands.Create(dbOption, schemaOption)); rootCommand.Add(ReportCommands.Create(dbOption, schemaOption)); rootCommand.Add(PhaseCommands.Create(dbOption, schemaOption)); var parseResult = rootCommand.Parse(args); return await parseResult.InvokeAsync();