2026-02-04 08:58:36 +08:00
|
|
|
using FCPModUpdater.Commands.Settings;
|
|
|
|
|
using FCPModUpdater.Services;
|
|
|
|
|
using FCPModUpdater.UI;
|
|
|
|
|
using Spectre.Console;
|
|
|
|
|
using Spectre.Console.Cli;
|
|
|
|
|
|
|
|
|
|
namespace FCPModUpdater.Commands;
|
|
|
|
|
|
|
|
|
|
public class ScanCommand : AsyncCommand<ModPathSettings>
|
|
|
|
|
{
|
|
|
|
|
public override async Task<int> ExecuteAsync(CommandContext context, ModPathSettings settings,
|
|
|
|
|
CancellationToken cancellationToken)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// Resolve mods directory
|
2026-02-04 13:35:36 +08:00
|
|
|
var modsDirectory = ModsDirectoryResolver.Resolve(settings.ModDirectory?.FullName, interactive: true);
|
2026-02-04 08:58:36 +08:00
|
|
|
if (modsDirectory == null)
|
|
|
|
|
{
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AnsiConsole.MarkupLine($"[grey]Using mods directory: {modsDirectory}[/]");
|
|
|
|
|
AnsiConsole.WriteLine();
|
|
|
|
|
|
|
|
|
|
// Initialize services
|
2026-02-04 11:44:21 +08:00
|
|
|
var gitService = new GitService();
|
2026-02-04 08:58:36 +08:00
|
|
|
var gitHubApiService = new GitHubApiService();
|
|
|
|
|
var modDiscoveryService = new ModDiscoveryService(gitService, gitHubApiService);
|
|
|
|
|
|
|
|
|
|
// Run interactive menu
|
|
|
|
|
var menu = new InteractiveMenu(
|
|
|
|
|
gitService,
|
|
|
|
|
gitHubApiService,
|
|
|
|
|
modDiscoveryService,
|
|
|
|
|
modsDirectory);
|
|
|
|
|
|
|
|
|
|
await menu.RunAsync(cancellationToken);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
catch (OperationCanceledException)
|
|
|
|
|
{
|
|
|
|
|
AnsiConsole.MarkupLine("[grey]Operation cancelled.[/]");
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
AnsiConsole.WriteException(ex);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|