From 8b6d4651f4605602b3a6a2700f64110eb3df8994 Mon Sep 17 00:00:00 2001 From: Timothy Baldridge Date: Tue, 12 Jul 2022 07:03:02 -0600 Subject: [PATCH] Add error indicator to compiler UI --- .../Views/Compilers/CompilerView.xaml | 17 +++++ Wabbajack.CLI/Program.cs | 3 +- Wabbajack.CLI/Verbs/Compile.cs | 72 +++++++++++++++++++ 3 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 Wabbajack.CLI/Verbs/Compile.cs diff --git a/Wabbajack.App.Wpf/Views/Compilers/CompilerView.xaml b/Wabbajack.App.Wpf/Views/Compilers/CompilerView.xaml index 92577a6e..89a37336 100644 --- a/Wabbajack.App.Wpf/Views/Compilers/CompilerView.xaml +++ b/Wabbajack.App.Wpf/Views/Compilers/CompilerView.xaml @@ -213,6 +213,23 @@ + + + + + + (); services.AddSingleton(); services.AddSingleton(); + services.AddSingleton(); services.AddSingleton(); - services.AddSingleton(); + services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); diff --git a/Wabbajack.CLI/Verbs/Compile.cs b/Wabbajack.CLI/Verbs/Compile.cs new file mode 100644 index 00000000..a769ec51 --- /dev/null +++ b/Wabbajack.CLI/Verbs/Compile.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.CommandLine.Invocation; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using Wabbajack.Compiler; +using Wabbajack.Downloaders; +using Wabbajack.Downloaders.GameFile; +using Wabbajack.DTOs.JsonConverters; +using Wabbajack.Networking.WabbajackClientApi; +using Wabbajack.Paths; +using Wabbajack.VFS; + +namespace Wabbajack.CLI.Verbs; + +public class Compile : IVerb +{ + private readonly ILogger _logger; + private readonly Client _wjClient; + private readonly DownloadDispatcher _dispatcher; + private readonly DTOSerializer _dtos; + private readonly IServiceProvider _serviceProvider; + private readonly FileHashCache _cache; + private readonly GameLocator _gameLocator; + private readonly CompilerSettingsInferencer _inferencer; + + public Compile(ILogger logger, Client wjClient, DownloadDispatcher dispatcher, DTOSerializer dtos, + FileHashCache cache, GameLocator gameLocator, IServiceProvider serviceProvider, CompilerSettingsInferencer inferencer) + { + _logger = logger; + _wjClient = wjClient; + _dispatcher = dispatcher; + _dtos = dtos; + _serviceProvider = serviceProvider; + _cache = cache; + _gameLocator = gameLocator; + _inferencer = inferencer; + } + + public Command MakeCommand() + { + var command = new Command("compile"); + command.Add(new Option(new[] {"-i", "-installPath"}, "Install Path")); + command.Add(new Option(new[] {"-o", "-output"}, "Output")); + command.Description = "Installs a modlist, compiles it, installs it again, verifies it"; + command.Handler = CommandHandler.Create(Run); + return command; + } + + public async Task Run(AbsolutePath installPath, AbsolutePath outputPath, + CancellationToken token) + { + _logger.LogInformation("Inferring settings"); + var inferredSettings = await _inferencer.InferFromRootPath(installPath); + if (inferredSettings == null) + { + _logger.LogInformation("Error inferencing settings"); + return 2; + } + + inferredSettings.UseGamePaths = true; + + var compiler = MO2Compiler.Create(_serviceProvider, inferredSettings); + var result = await compiler.Begin(token); + if (!result) + return result ? 0 : 3; + + return 0; + } +} \ No newline at end of file