public static Installation?GetTargetInstallation(string?path, string promptTitle) { var installations = new List <Installation>(); AnsiConsole .Status() .Start("Discovering [green]Escape From Tarkov[/] installations...", _ => { installations = Installation .DiscoverInstallations() .Distinct() .ToList(); }); if (path is not null && Installation.TryDiscoverInstallation(path, out var installation)) { installations.Add(installation); } installations = installations .Distinct() .OrderBy(i => i.Location) .ToList(); switch (installations.Count) { case 0: AnsiConsole.MarkupLine("[yellow]No [green]EscapeFromTarkov[/] installation found, please re-run this installer, passing the installation path as argument.[/]"); return(null); case 1: var first = installations.First(); return(AnsiConsole.Confirm($"Continue with [green]EscapeFromTarkov ({first.Version})[/] in [blue]{first.Location}[/] ?") ? first : null); default: var prompt = new SelectionPrompt <Installation> { Converter = i => i.Location, Title = promptTitle }; prompt.AddChoices(installations); return(AnsiConsole.Prompt(prompt)); } }
private static Installation?GetTargetInstallation(Settings settings) { var installations = new List <Installation>(); AnsiConsole .Status() .Start("Discovering [green]Escape From Tarkov[/] installations...", _ => { installations = Installation .DiscoverInstallations() .Distinct() .ToList(); }); if (settings.Path is not null && Installation.TryDiscoverInstallation(settings.Path, out var installation)) { installations.Add(installation); } installations = installations .Distinct() .OrderBy(i => i.Location) .ToList(); switch (installations.Count) { case 0: AnsiConsole.MarkupLine("[yellow]No [green]EscapeFromTarkov[/] installation found, please re-run this installer, passing the installation path as argument.[/]"); return(null); case 1: return(installations.First()); default: var prompt = new SelectionPrompt <Installation> { Converter = i => i.Location, Title = "Please select where to install the trainer" }; prompt.AddChoices(installations); return(AnsiConsole.Prompt(prompt)); } }