namespace EpicMorg.Atlassian.Downloader; using EpicMorg.Atlassian.Downloader.Core; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Serilog; using System; using System.Threading.Tasks; public class Program { /// /// Atlassian archive downloader. See https://github.com/EpicMorg/atlassian-downloader for more info /// /// Action to perform /// Override output directory to download /// Override URIs to import /// Show credits banner /// Override target version to download some product. Advice: Use it with "customFeed". /// Skip compare of file sizes if a local file already exists. Existing file will be skipped to check and redownload. /// Set custom user agent via this feature flag. /// Set custom count of download retries. /// Set custom delay between retries (in milliseconds). static async Task Main( string? outputDir = default, Uri[]? customFeed = null, DownloadAction action = DownloadAction.Download, bool about = false, string? productVersion = null, bool skipFileCheck = false, int maxRetries = 5, int delayBetweenRetries = 2500, string userAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:101.0) Gecko/20100101 Firefox/101.0") => await Host .CreateDefaultBuilder() .ConfigureHostConfiguration(configHost => configHost.AddEnvironmentVariables()) .ConfigureAppConfiguration((ctx, configuration) => configuration .SetBasePath(System.AppContext.BaseDirectory) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) .AddJsonFile($"appsettings.{ctx.HostingEnvironment.EnvironmentName}.json", optional: true, reloadOnChange: true) .AddEnvironmentVariables()) .ConfigureServices((ctx, services) => services .AddOptions() .AddLogging(builder => { Log.Logger = new LoggerConfiguration() .ReadFrom.Configuration(ctx.Configuration) .CreateLogger(); _ = builder .ClearProviders() .AddSerilog(dispose: true); }) .AddHostedService() .AddSingleton(new DownloaderOptions( outputDir ?? Environment.CurrentDirectory, customFeed, action, about, productVersion, skipFileCheck, userAgent, maxRetries, delayBetweenRetries)) .AddHttpClient()) .RunConsoleAsync() .ConfigureAwait(false); }