Skip to content

Commit

Permalink
made 'main' method async
Browse files Browse the repository at this point in the history
  • Loading branch information
waylaa committed Dec 6, 2023
1 parent 3f7d2df commit 6b08547
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions OsuCollectionDownloader/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace OsuCollectionDownloader;

internal sealed class Program
{
private static Task<int> Main(string[] args)
private static async Task<int> Main(string[] args)
{
Option<int> id = new("--id", "The ID of a collection.");
Option<DirectoryInfo> osuSongsDirectory = new("--osu-songs-directory", "A directory where the downloaded beatmaps will be saved and extracted.");
Expand Down Expand Up @@ -39,15 +39,14 @@ private static Task<int> Main(string[] args)
ctx.ParseResult.GetValueForOption(osuSongsDirectory)!,
ctx.ParseResult.GetValueForOption(osdbFileDirectory)
),
ctx.BindingContext.GetRequiredService<OsuCollectorService>(),
ctx.BindingContext.GetRequiredService<IHttpClientFactory>(),
ctx.BindingContext.GetRequiredService<ILogger<DownloadProcessor>>()
);

return downloader.DownloadAsync(ctx.GetCancellationToken());
});

return new CommandLineBuilder(rootCommand)
return await new CommandLineBuilder(rootCommand)
.UseDefaults()
.AddMiddleware(middleware =>
{
Expand All @@ -66,9 +65,7 @@ private static Task<int> Main(string[] args)
client.DefaultRequestHeaders.Accept.Add(new("application/json"));
client.DefaultRequestHeaders.Accept.Add(new("application/octet-stream"));
})
.Services
.AddSingleton<OsuCollectorService>()
.BuildServiceProvider();
.Services.BuildServiceProvider();

middleware.BindingContext.AddService(_ => provider.GetRequiredService<IHttpClientFactory>());
middleware.BindingContext.AddService(_ => provider.GetRequiredService<ILogger<DownloadProcessor>>());
Expand Down

0 comments on commit 6b08547

Please sign in to comment.