Update to Spectre Console 0.55

This commit is contained in:
Canon
2026-04-10 05:39:37 +08:00
parent 4cac3717c9
commit 99ffe7d179
4 changed files with 29 additions and 23 deletions
+4 -4
View File
@@ -1,30 +1,30 @@
using FCPModUpdater.Commands.Settings;
using FCPModUpdater.Services;
using FCPModUpdater.UI;
using JetBrains.Annotations;
using Spectre.Console;
using Spectre.Console.Cli;
namespace FCPModUpdater.Commands;
[UsedImplicitly]
public class ScanCommand(
IGitService gitService,
IGitHubApiService gitHubApiService,
IModDiscoveryService modDiscoveryService,
UpdateCheckService updateCheckService) : AsyncCommand<ModPathSettings>
{
public override async Task<int> ExecuteAsync(CommandContext context, ModPathSettings settings,
protected override async Task<int> ExecuteAsync(CommandContext context, ModPathSettings settings,
CancellationToken cancellationToken)
{
try
{
var modsDirectory = ModsDirectoryResolver.Resolve(settings.ModDirectory?.FullName, interactive: true);
if (modsDirectory == null)
return 1;
AnsiConsole.MarkupLine($"[grey]Using mods directory: {modsDirectory}[/]");
AnsiConsole.WriteLine();
var updateCheckTask = updateCheckService.CheckForUpdateAsync(cancellationToken);
Task<UpdateCheckResult?> updateCheckTask = updateCheckService.CheckForUpdateAsync(cancellationToken);
var menu = new InteractiveMenu(
gitService,
+8 -10
View File
@@ -17,23 +17,21 @@ public class UpdateCommand(
public static IReadOnlyList<InstalledMod> GetUpdateableMods(IReadOnlyList<InstalledMod> mods)
=> mods.Where(m => m.Source == ModSource.Git && m.Status == ModStatus.Behind).ToList();
public override async Task<int> ExecuteAsync(CommandContext context, ModPathSettings settings,
CancellationToken cancellationToken)
protected override async Task<int> ExecuteAsync(CommandContext context, ModPathSettings settings,
CancellationToken ct)
{
try
{
var modsDirectory = ModsDirectoryResolver.Resolve(settings.ModDirectory?.FullName, interactive: false);
if (modsDirectory == null)
return 1;
AnsiConsole.MarkupLine($"[grey]Using mods directory: {modsDirectory}[/]");
AnsiConsole.WriteLine();
var updateCheckTask = updateCheckService.CheckForUpdateAsync(cancellationToken);
Task<UpdateCheckResult?> updateCheckTask = updateCheckService.CheckForUpdateAsync(ct);
var mods = await ProgressReporter.WithStatusAsync(
"Scanning mods directory...",
async () => await modDiscoveryService.DiscoverModsAsync(modsDirectory, ct: cancellationToken));
async () => await modDiscoveryService.DiscoverModsAsync(modsDirectory, ct: ct));
var updateableMods = GetUpdateableMods(mods);
@@ -54,16 +52,16 @@ public class UpdateCommand(
var results = await ProgressReporter.WithBatchProgressAsync(
"Updating mods",
updateableMods,
m => m.Name,
installedMod => installedMod.Name,
async (mod, progress) =>
{
progress.Report(25);
var fetchOk = await gitService.FetchAsync(mod.Path, ct: cancellationToken);
var fetchOk = await gitService.FetchAsync(mod.Path, ct: ct);
if (!fetchOk)
return (false, "Fetch failed");
progress.Report(50);
var pullOk = await gitService.PullAsync(mod.Path, ct: cancellationToken);
var pullOk = await gitService.PullAsync(mod.Path, ct: ct);
progress.Report(100);
return (pullOk, pullOk ? null : "Pull failed");
@@ -71,7 +69,7 @@ public class UpdateCommand(
ModTableRenderer.RenderUpdateSummary(results);
var updateResult = await updateCheckTask;
UpdateCheckResult? updateResult = await updateCheckTask;
if (updateResult != null)
{
AnsiConsole.WriteLine();
+2 -2
View File
@@ -23,8 +23,8 @@
<PackageReference Include="JetBrains.Annotations" Version="2025.2.4" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.5" />
<PackageReference Include="Microsoft.Extensions.Http" Version="10.0.5" />
<PackageReference Include="Spectre.Console" Version="0.54.0" />
<PackageReference Include="Spectre.Console.Cli" Version="0.53.1" />
<PackageReference Include="Spectre.Console" Version="0.55.0" />
<PackageReference Include="Spectre.Console.Cli" Version="0.55.0" />
</ItemGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
+15 -7
View File
@@ -39,17 +39,20 @@
},
"Spectre.Console": {
"type": "Direct",
"requested": "[0.54.0, )",
"resolved": "0.54.0",
"contentHash": "StDXCFayfy0yB1xzUHT2tgEpV1/HFTiS4JgsAQS49EYTfMixSwwucaQs/bIOCwXjWwIQTMuxjUIxcB5XsJkFJA=="
"requested": "[0.55.0, )",
"resolved": "0.55.0",
"contentHash": "2TVhUHFsDux0Z+y2Hv4bFsOMuON4SuotEEKkMparFkp5Rm259naaaEQrN4Sv6C1cbsiGKPjfkJDGgUp+hZPjTw==",
"dependencies": {
"Spectre.Console.Ansi": "0.55.0"
}
},
"Spectre.Console.Cli": {
"type": "Direct",
"requested": "[0.53.1, )",
"resolved": "0.53.1",
"contentHash": "y//7ZZ0shhvgXzoJXJzMaLGA4dPem8qCbkyv9khfE8NQDlH4hPVsHOHYoz6uzAwiTX9Yd7OnX3wNOX/wRfPUOg==",
"requested": "[0.55.0, )",
"resolved": "0.55.0",
"contentHash": "cFJTB1te4eaAICd4Zp+8T/kiRn1ikQxgGqmoNarb1qoQ/7LzHAvVQ62x5U9GW3E0QI7sZLcXIIoq4CpqgTx42Q==",
"dependencies": {
"Spectre.Console": "0.53.1"
"Spectre.Console": "0.55.0"
}
},
"Microsoft.Extensions.Configuration": {
@@ -145,6 +148,11 @@
"type": "Transitive",
"resolved": "10.0.5",
"contentHash": "/HUHJ0tw/LQvD0DZrz50eQy/3z7PfX7WWEaXnjKTV9/TNdcgFlNTZGo49QhS7PTmhDqMyHRMqAXSBxLh0vso4g=="
},
"Spectre.Console.Ansi": {
"type": "Transitive",
"resolved": "0.55.0",
"contentHash": "GIfgOvuF8MpU52bprhwtDEtx0gmVIGOepM8bw0lH/TSMD0rg1Xp+5Y53kPG8rFVdcpbNANlhDQ5mEVVPO3/2Tg=="
}
}
}