mirror of
https://github.com/real-zony/ZonyLrcToolsX.git
synced 2025-09-06 05:36:53 +00:00
feat: Add auto-detect update feature.
This commit is contained in:
26
src/ZonyLrcTools.Cli/Infrastructure/UpdaterHostedService.cs
Normal file
26
src/ZonyLrcTools.Cli/Infrastructure/UpdaterHostedService.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using ZonyLrcTools.Common.Updater;
|
||||
|
||||
namespace ZonyLrcTools.Cli.Infrastructure;
|
||||
|
||||
public class UpdaterHostedService : IHostedService
|
||||
{
|
||||
private readonly IUpdater _updater;
|
||||
|
||||
public UpdaterHostedService(IUpdater updater)
|
||||
{
|
||||
_updater = updater;
|
||||
}
|
||||
|
||||
public async Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
await _updater.CheckUpdateAsync();
|
||||
}
|
||||
|
||||
public Task StopAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
@@ -11,6 +11,7 @@ using Serilog.Events;
|
||||
using Serilog.Sinks.SystemConsole.Themes;
|
||||
using ZonyLrcTools.Cli.Commands;
|
||||
using ZonyLrcTools.Cli.Commands.SubCommand;
|
||||
using ZonyLrcTools.Cli.Infrastructure;
|
||||
using ZonyLrcTools.Cli.Infrastructure.Logging;
|
||||
using ZonyLrcTools.Common.Infrastructure.DependencyInject;
|
||||
using ZonyLrcTools.Common.Infrastructure.Exceptions;
|
||||
@@ -90,6 +91,7 @@ namespace ZonyLrcTools.Cli
|
||||
services.BeginAutoDependencyInject<IWarpHttpClient>();
|
||||
services.ConfigureConfiguration();
|
||||
services.ConfigureToolService();
|
||||
services.AddHostedService<UpdaterHostedService>();
|
||||
})
|
||||
.RunCommandLineApplicationAsync<Program>(args);
|
||||
}
|
||||
|
Reference in New Issue
Block a user