2021-09-27 12:42:46 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.CommandLine;
|
|
|
|
|
using System.CommandLine.IO;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Net.Http;
|
|
|
|
|
using System.Text.Json;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Hosting;
|
2022-05-29 04:19:25 +00:00
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using NLog.Extensions.Logging;
|
|
|
|
|
using NLog.Targets;
|
2021-09-27 12:42:46 +00:00
|
|
|
|
using Octokit;
|
|
|
|
|
using Wabbajack.CLI.TypeConverters;
|
2020-01-31 22:38:56 +00:00
|
|
|
|
using Wabbajack.CLI.Verbs;
|
2021-09-27 12:42:46 +00:00
|
|
|
|
using Wabbajack.DTOs.GitHub;
|
2022-01-08 17:39:23 +00:00
|
|
|
|
using Wabbajack.DTOs.Interventions;
|
2021-09-27 12:42:46 +00:00
|
|
|
|
using Wabbajack.Networking.Http;
|
|
|
|
|
using Wabbajack.Networking.Http.Interfaces;
|
|
|
|
|
using Wabbajack.Networking.WabbajackClientApi;
|
|
|
|
|
using Wabbajack.Paths;
|
|
|
|
|
using Wabbajack.Paths.IO;
|
|
|
|
|
using Wabbajack.Server.Lib;
|
|
|
|
|
using Wabbajack.Services.OSIntegrated;
|
|
|
|
|
using Wabbajack.VFS;
|
|
|
|
|
using Client = Wabbajack.Networking.GitHub.Client;
|
2020-01-31 22:38:56 +00:00
|
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
|
namespace Wabbajack.CLI;
|
|
|
|
|
|
|
|
|
|
internal class Program
|
2020-01-31 22:38:56 +00:00
|
|
|
|
{
|
2021-10-23 16:51:17 +00:00
|
|
|
|
private static async Task<int> Main(string[] args)
|
2020-01-31 22:38:56 +00:00
|
|
|
|
{
|
2021-10-23 16:51:17 +00:00
|
|
|
|
TypeDescriptor.AddAttributes(typeof(AbsolutePath),
|
|
|
|
|
new TypeConverterAttribute(typeof(AbsolutePathTypeConverter)));
|
|
|
|
|
TypeDescriptor.AddAttributes(typeof(List),
|
|
|
|
|
new TypeConverterAttribute(typeof(ModListCategoryConverter)));
|
2021-09-27 12:42:46 +00:00
|
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
|
var host = Host.CreateDefaultBuilder(Array.Empty<string>())
|
2022-05-29 04:19:25 +00:00
|
|
|
|
.ConfigureLogging(AddLogging)
|
2021-10-23 16:51:17 +00:00
|
|
|
|
.ConfigureServices((host, services) =>
|
|
|
|
|
{
|
|
|
|
|
services.AddSingleton(new JsonSerializerOptions());
|
|
|
|
|
services.AddSingleton<HttpClient, HttpClient>();
|
|
|
|
|
services.AddSingleton<IHttpDownloader, SingleThreadedDownloader>();
|
|
|
|
|
services.AddSingleton<IConsole, SystemConsole>();
|
|
|
|
|
services.AddSingleton<CommandLineBuilder, CommandLineBuilder>();
|
|
|
|
|
services.AddSingleton<TemporaryFileManager>();
|
|
|
|
|
services.AddSingleton<FileExtractor.FileExtractor>();
|
|
|
|
|
services.AddSingleton(new ParallelOptions {MaxDegreeOfParallelism = Environment.ProcessorCount});
|
|
|
|
|
services.AddSingleton<Client>();
|
|
|
|
|
services.AddSingleton<Networking.WabbajackClientApi.Client>();
|
|
|
|
|
services.AddSingleton(s => new GitHubClient(new ProductHeaderValue("wabbajack")));
|
2021-09-27 12:42:46 +00:00
|
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
|
services.AddOSIntegrated();
|
|
|
|
|
services.AddServerLib();
|
2021-09-27 12:42:46 +00:00
|
|
|
|
|
|
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
|
services.AddTransient<Context>();
|
|
|
|
|
services.AddSingleton<IVerb, HashFile>();
|
|
|
|
|
services.AddSingleton<IVerb, VFSIndexFolder>();
|
|
|
|
|
services.AddSingleton<IVerb, Encrypt>();
|
|
|
|
|
services.AddSingleton<IVerb, Decrypt>();
|
|
|
|
|
services.AddSingleton<IVerb, ValidateLists>();
|
|
|
|
|
services.AddSingleton<IVerb, DownloadCef>();
|
|
|
|
|
services.AddSingleton<IVerb, DownloadUrl>();
|
2021-11-30 03:22:12 +00:00
|
|
|
|
services.AddSingleton<IVerb, GenerateMetricsReports>();
|
2021-12-17 23:40:45 +00:00
|
|
|
|
services.AddSingleton<IVerb, ForceHeal>();
|
|
|
|
|
services.AddSingleton<IVerb, MirrorFile>();
|
2022-01-08 17:39:23 +00:00
|
|
|
|
services.AddSingleton<IVerb, SteamLogin>();
|
2022-01-08 22:03:39 +00:00
|
|
|
|
services.AddSingleton<IVerb, SteamAppDumpInfo>();
|
2022-01-09 05:40:23 +00:00
|
|
|
|
services.AddSingleton<IVerb, SteamDownloadFile>();
|
2022-01-18 03:56:29 +00:00
|
|
|
|
services.AddSingleton<IVerb, UploadToNexus>();
|
2022-02-10 23:57:44 +00:00
|
|
|
|
services.AddSingleton<IVerb, ListCreationClubContent>();
|
2022-03-30 03:39:48 +00:00
|
|
|
|
services.AddSingleton<IVerb, ListModlists>();
|
2022-02-12 00:47:02 +00:00
|
|
|
|
services.AddSingleton<IVerb, Extract>();
|
2022-05-14 14:18:03 +00:00
|
|
|
|
services.AddSingleton<IVerb, DumpZipInfo>();
|
2022-05-23 21:07:07 +00:00
|
|
|
|
services.AddSingleton<IVerb, Install>();
|
2022-07-12 13:03:02 +00:00
|
|
|
|
services.AddSingleton<IVerb, Compile>();
|
2022-05-27 05:41:11 +00:00
|
|
|
|
services.AddSingleton<IVerb, InstallCompileInstallVerify>();
|
2022-07-12 13:03:02 +00:00
|
|
|
|
services.AddSingleton<IVerb, HashUrlString>();
|
2022-06-20 23:21:04 +00:00
|
|
|
|
services.AddSingleton<IVerb, DownloadAll>();
|
2022-09-12 23:06:14 +00:00
|
|
|
|
services.AddSingleton<IVerb, ModlistReport>();
|
2022-09-26 21:58:33 +00:00
|
|
|
|
services.AddSingleton<IVerb, ListGames>();
|
2022-01-08 17:39:23 +00:00
|
|
|
|
|
|
|
|
|
services.AddSingleton<IUserInterventionHandler, UserInterventionHandler>();
|
2021-10-23 16:51:17 +00:00
|
|
|
|
}).Build();
|
2021-09-27 12:42:46 +00:00
|
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
|
var service = host.Services.GetService<CommandLineBuilder>();
|
|
|
|
|
return await service!.Run(args);
|
2020-01-31 22:38:56 +00:00
|
|
|
|
}
|
2022-05-29 04:19:25 +00:00
|
|
|
|
|
|
|
|
|
private static void AddLogging(ILoggingBuilder loggingBuilder)
|
|
|
|
|
{
|
|
|
|
|
var config = new NLog.Config.LoggingConfiguration();
|
|
|
|
|
|
|
|
|
|
var fileTarget = new FileTarget("file")
|
|
|
|
|
{
|
|
|
|
|
FileName = "logs/wabbajack-cli.current.log",
|
|
|
|
|
ArchiveFileName = "logs/wabbajack-cli.{##}.log",
|
|
|
|
|
ArchiveOldFileOnStartup = true,
|
|
|
|
|
MaxArchiveFiles = 10,
|
|
|
|
|
Layout = "${processtime} [${level:uppercase=true}] (${logger}) ${message:withexception=true}",
|
|
|
|
|
Header = "############ Wabbajack log file - ${longdate} ############"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var consoleTarget = new ConsoleTarget("console")
|
|
|
|
|
{
|
|
|
|
|
Layout = "${processtime} [${level:uppercase=true}] ${message:withexception=true}",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
config.AddRuleForAllLevels(fileTarget);
|
|
|
|
|
config.AddRuleForAllLevels(consoleTarget);
|
|
|
|
|
|
|
|
|
|
loggingBuilder.ClearProviders();
|
|
|
|
|
loggingBuilder.SetMinimumLevel(LogLevel.Trace);
|
|
|
|
|
loggingBuilder.AddNLog(config);
|
|
|
|
|
}
|
2021-09-27 12:42:46 +00:00
|
|
|
|
}
|