diff --git a/Wabbajack.CLI/CommandLineBuilder.cs b/Wabbajack.CLI.Builder/CommandLineBuilder.cs similarity index 71% rename from Wabbajack.CLI/CommandLineBuilder.cs rename to Wabbajack.CLI.Builder/CommandLineBuilder.cs index 7b1a6398..9ce66177 100644 --- a/Wabbajack.CLI/CommandLineBuilder.cs +++ b/Wabbajack.CLI.Builder/CommandLineBuilder.cs @@ -1,31 +1,20 @@ -using System; -using System.Collections.Generic; using System.CommandLine; +using System.CommandLine.Builder; using System.CommandLine.Invocation; using System.CommandLine.NamingConventionBinder; -using System.ComponentModel.Design; -using System.Linq; -using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; -using Wabbajack.CLI.Verbs; using Wabbajack.Paths; -using Wabbajack.Services.OSIntegrated; -namespace Wabbajack.CLI; +namespace Wabbajack.CLI.Builder; -public partial class CommandLineBuilder +public class CommandLineBuilder { private static IServiceProvider _provider; - public CommandLineBuilder(IServiceProvider provider, IConsole console, LoggingRateLimiterReporter _) + public CommandLineBuilder(IServiceProvider provider, IConsole console) { _provider = provider; } - - static CommandLineBuilder() - { - RegisterAll(); - } - + public async Task Run(string[] args) { var root = new RootCommand(); @@ -58,7 +47,7 @@ public partial class CommandLineBuilder }; - private Command MakeCommend(Type verbType, Func verbHandler, VerbDefinition definition) + private Command MakeCommend(Type verbType, Func verbHandler, VerbDefinition definition) { var command = new Command(definition.Name, definition.Description); foreach (var option in definition.Options) @@ -73,9 +62,9 @@ public partial class CommandLineBuilder { private IServiceProvider _provider; private Type _type; - private readonly Func _delgate; + private readonly Func _delgate; - public HandlerDelegate(IServiceProvider provider, Type type, Func inner) + public HandlerDelegate(IServiceProvider provider, Type type, Func inner) { _provider = provider; _type = type; @@ -83,22 +72,23 @@ public partial class CommandLineBuilder } public int Invoke(InvocationContext context) { - var service = (IVerb)_provider.GetRequiredService(_type); + var service = _provider.GetRequiredService(_type); var handler = CommandHandler.Create(_delgate(service)); return handler.Invoke(context); } public Task InvokeAsync(InvocationContext context) { - var service = (IVerb)_provider.GetRequiredService(_type); + var service = _provider.GetRequiredService(_type); var handler = CommandHandler.Create(_delgate(service)); return handler.InvokeAsync(context); } } - private static List<(Type Type, VerbDefinition Definition, Func Handler)> _commands { get; set; } = new(); + private static List<(Type Type, VerbDefinition Definition, Func Handler)> _commands { get; set; } = new(); public static IEnumerable Verbs => _commands.Select(c => c.Type); - public static void RegisterCommand(VerbDefinition definition, Func handler) + + public static void RegisterCommand(VerbDefinition definition, Func handler) { _commands.Add((typeof(T), definition, handler)); @@ -120,17 +110,3 @@ public record VerbDefinition(string Name, string Description, OptionDefinition[] { } -public static class CommandLineBuilderExtensions -{ - public static IServiceCollection AddCommands(this IServiceCollection services) - { - services.AddSingleton(); - - foreach (var verb in CommandLineBuilder.Verbs) - { - services.AddSingleton(verb); - } - - return services; - } -} \ No newline at end of file diff --git a/Wabbajack.CLI.Builder/Wabbajack.CLI.Builder.csproj b/Wabbajack.CLI.Builder/Wabbajack.CLI.Builder.csproj new file mode 100644 index 00000000..9ae77885 --- /dev/null +++ b/Wabbajack.CLI.Builder/Wabbajack.CLI.Builder.csproj @@ -0,0 +1,23 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + + + + + + + diff --git a/Wabbajack.CLI/Program.cs b/Wabbajack.CLI/Program.cs index 81c7d407..919a220b 100644 --- a/Wabbajack.CLI/Program.cs +++ b/Wabbajack.CLI/Program.cs @@ -18,6 +18,7 @@ using Wabbajack.Server.Lib; using Wabbajack.Services.OSIntegrated; using Wabbajack.VFS; using Client = Wabbajack.Networking.GitHub.Client; +using Wabbajack.CLI.Builder; namespace Wabbajack.CLI; @@ -46,7 +47,13 @@ internal class Program services.AddTransient(); - services.AddCommands(); + + services.AddSingleton(); + services.AddCLIVerbs(); + + + + services.AddSingleton(); }).Build(); diff --git a/Wabbajack.CLI/VerbRegistration.cs b/Wabbajack.CLI/VerbRegistration.cs index a04dbf5c..0e7154a7 100644 --- a/Wabbajack.CLI/VerbRegistration.cs +++ b/Wabbajack.CLI/VerbRegistration.cs @@ -1,32 +1,57 @@  +using Microsoft.Extensions.DependencyInjection; namespace Wabbajack.CLI; using Wabbajack.CLI.Verbs; +using Wabbajack.CLI.Builder; -public partial class CommandLineBuilder { +public static class CommandLineBuilderExtensions{ -private static void RegisterAll() { -RegisterCommand(Compile.Definition, c => ((Compile)c).Run); -RegisterCommand(Decrypt.Definition, c => ((Decrypt)c).Run); -RegisterCommand(DownloadAll.Definition, c => ((DownloadAll)c).Run); -RegisterCommand(DownloadUrl.Definition, c => ((DownloadUrl)c).Run); -RegisterCommand(DumpZipInfo.Definition, c => ((DumpZipInfo)c).Run); -RegisterCommand(Encrypt.Definition, c => ((Encrypt)c).Run); -RegisterCommand(Extract.Definition, c => ((Extract)c).Run); -RegisterCommand(ForceHeal.Definition, c => ((ForceHeal)c).Run); -RegisterCommand(HashFile.Definition, c => ((HashFile)c).Run); -RegisterCommand(HashUrlString.Definition, c => ((HashUrlString)c).Run); -RegisterCommand(Install.Definition, c => ((Install)c).Run); -RegisterCommand(InstallCompileInstallVerify.Definition, c => ((InstallCompileInstallVerify)c).Run); -RegisterCommand(ListCreationClubContent.Definition, c => ((ListCreationClubContent)c).Run); -RegisterCommand(ListGames.Definition, c => ((ListGames)c).Run); -RegisterCommand(ListModlists.Definition, c => ((ListModlists)c).Run); -RegisterCommand(MirrorFile.Definition, c => ((MirrorFile)c).Run); -RegisterCommand(ModlistReport.Definition, c => ((ModlistReport)c).Run); -RegisterCommand(SteamDownloadFile.Definition, c => ((SteamDownloadFile)c).Run); -RegisterCommand(SteamDumpAppInfo.Definition, c => ((SteamDumpAppInfo)c).Run); -RegisterCommand(SteamLogin.Definition, c => ((SteamLogin)c).Run); -RegisterCommand(UploadToNexus.Definition, c => ((UploadToNexus)c).Run); -RegisterCommand(ValidateLists.Definition, c => ((ValidateLists)c).Run); -RegisterCommand(VFSIndex.Definition, c => ((VFSIndex)c).Run); +public static void AddCLIVerbs(this IServiceCollection services) { +CommandLineBuilder.RegisterCommand(Compile.Definition, c => ((Compile)c).Run); +services.AddSingleton(); +CommandLineBuilder.RegisterCommand(Decrypt.Definition, c => ((Decrypt)c).Run); +services.AddSingleton(); +CommandLineBuilder.RegisterCommand(DownloadAll.Definition, c => ((DownloadAll)c).Run); +services.AddSingleton(); +CommandLineBuilder.RegisterCommand(DownloadUrl.Definition, c => ((DownloadUrl)c).Run); +services.AddSingleton(); +CommandLineBuilder.RegisterCommand(DumpZipInfo.Definition, c => ((DumpZipInfo)c).Run); +services.AddSingleton(); +CommandLineBuilder.RegisterCommand(Encrypt.Definition, c => ((Encrypt)c).Run); +services.AddSingleton(); +CommandLineBuilder.RegisterCommand(Extract.Definition, c => ((Extract)c).Run); +services.AddSingleton(); +CommandLineBuilder.RegisterCommand(ForceHeal.Definition, c => ((ForceHeal)c).Run); +services.AddSingleton(); +CommandLineBuilder.RegisterCommand(HashFile.Definition, c => ((HashFile)c).Run); +services.AddSingleton(); +CommandLineBuilder.RegisterCommand(HashUrlString.Definition, c => ((HashUrlString)c).Run); +services.AddSingleton(); +CommandLineBuilder.RegisterCommand(Install.Definition, c => ((Install)c).Run); +services.AddSingleton(); +CommandLineBuilder.RegisterCommand(InstallCompileInstallVerify.Definition, c => ((InstallCompileInstallVerify)c).Run); +services.AddSingleton(); +CommandLineBuilder.RegisterCommand(ListCreationClubContent.Definition, c => ((ListCreationClubContent)c).Run); +services.AddSingleton(); +CommandLineBuilder.RegisterCommand(ListGames.Definition, c => ((ListGames)c).Run); +services.AddSingleton(); +CommandLineBuilder.RegisterCommand(ListModlists.Definition, c => ((ListModlists)c).Run); +services.AddSingleton(); +CommandLineBuilder.RegisterCommand(MirrorFile.Definition, c => ((MirrorFile)c).Run); +services.AddSingleton(); +CommandLineBuilder.RegisterCommand(ModlistReport.Definition, c => ((ModlistReport)c).Run); +services.AddSingleton(); +CommandLineBuilder.RegisterCommand(SteamDownloadFile.Definition, c => ((SteamDownloadFile)c).Run); +services.AddSingleton(); +CommandLineBuilder.RegisterCommand(SteamDumpAppInfo.Definition, c => ((SteamDumpAppInfo)c).Run); +services.AddSingleton(); +CommandLineBuilder.RegisterCommand(SteamLogin.Definition, c => ((SteamLogin)c).Run); +services.AddSingleton(); +CommandLineBuilder.RegisterCommand(UploadToNexus.Definition, c => ((UploadToNexus)c).Run); +services.AddSingleton(); +CommandLineBuilder.RegisterCommand(ValidateLists.Definition, c => ((ValidateLists)c).Run); +services.AddSingleton(); +CommandLineBuilder.RegisterCommand(VFSIndex.Definition, c => ((VFSIndex)c).Run); +services.AddSingleton(); } } \ No newline at end of file diff --git a/Wabbajack.CLI/VerbRegistration.tt b/Wabbajack.CLI/VerbRegistration.tt index b6655fe3..6719d6d3 100644 --- a/Wabbajack.CLI/VerbRegistration.tt +++ b/Wabbajack.CLI/VerbRegistration.tt @@ -5,19 +5,22 @@ <#@ import namespace="System.IO"#> <#@ import namespace="System.Collections.Generic" #> +using Microsoft.Extensions.DependencyInjection; namespace Wabbajack.CLI; using Wabbajack.CLI.Verbs; +using Wabbajack.CLI.Builder; -public partial class CommandLineBuilder { +public static class CommandLineBuilderExtensions{ -private static void RegisterAll() { +public static void AddCLIVerbs(this IServiceCollection services) { <# foreach (var verb in Directory.EnumerateFiles("Verbs")) { var klass = verb.Split('\\').Last().Split('.').First(); if (klass == "IVerb") continue; #> -RegisterCommand<<#=klass#>>(<#=klass#>.Definition, c => ((<#=klass#>)c).Run); +CommandLineBuilder.RegisterCommand<<#=klass#>>(<#=klass#>.Definition, c => ((<#=klass#>)c).Run); +services.AddSingleton<<#=klass#>>(); <# } diff --git a/Wabbajack.CLI/Verbs/Compile.cs b/Wabbajack.CLI/Verbs/Compile.cs index 4abb1e5f..692a8e0b 100644 --- a/Wabbajack.CLI/Verbs/Compile.cs +++ b/Wabbajack.CLI/Verbs/Compile.cs @@ -4,6 +4,7 @@ using System.CommandLine.NamingConventionBinder; using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Logging; +using Wabbajack.CLI.Builder; using Wabbajack.Compiler; using Wabbajack.Downloaders; using Wabbajack.Downloaders.GameFile; @@ -14,7 +15,7 @@ using Wabbajack.VFS; namespace Wabbajack.CLI.Verbs; -public class Compile : IVerb +public class Compile { private readonly ILogger _logger; private readonly Client _wjClient; diff --git a/Wabbajack.CLI/Verbs/Decrypt.cs b/Wabbajack.CLI/Verbs/Decrypt.cs index 4ec4c81f..d6a22c4a 100644 --- a/Wabbajack.CLI/Verbs/Decrypt.cs +++ b/Wabbajack.CLI/Verbs/Decrypt.cs @@ -4,13 +4,14 @@ using System.CommandLine.Invocation; using System.CommandLine.NamingConventionBinder; using System.Threading.Tasks; using Microsoft.Extensions.Logging; +using Wabbajack.CLI.Builder; using Wabbajack.Paths; using Wabbajack.Paths.IO; using Wabbajack.Services.OSIntegrated; namespace Wabbajack.CLI.Verbs; -public class Decrypt : IVerb +public class Decrypt { private readonly ILogger _logger; diff --git a/Wabbajack.CLI/Verbs/DownloadAll.cs b/Wabbajack.CLI/Verbs/DownloadAll.cs index 3dacba1f..90e171ca 100644 --- a/Wabbajack.CLI/Verbs/DownloadAll.cs +++ b/Wabbajack.CLI/Verbs/DownloadAll.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Logging; +using Wabbajack.CLI.Builder; using Wabbajack.Common; using Wabbajack.Downloaders; using Wabbajack.DTOs; @@ -20,7 +21,7 @@ using Wabbajack.VFS; namespace Wabbajack.CLI.Verbs; -public class DownloadAll : IVerb +public class DownloadAll { private readonly DownloadDispatcher _dispatcher; private readonly ILogger _logger; diff --git a/Wabbajack.CLI/Verbs/DownloadUrl.cs b/Wabbajack.CLI/Verbs/DownloadUrl.cs index 5ffbbc54..7f8a15ee 100644 --- a/Wabbajack.CLI/Verbs/DownloadUrl.cs +++ b/Wabbajack.CLI/Verbs/DownloadUrl.cs @@ -5,6 +5,7 @@ using System.CommandLine.NamingConventionBinder; using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Logging; +using Wabbajack.CLI.Builder; using Wabbajack.Common; using Wabbajack.Downloaders; using Wabbajack.DTOs; @@ -13,7 +14,7 @@ using Wabbajack.Paths.IO; namespace Wabbajack.CLI.Verbs; -public class DownloadUrl : IVerb +public class DownloadUrl { private readonly DownloadDispatcher _dispatcher; private readonly ILogger _logger; diff --git a/Wabbajack.CLI/Verbs/DumpZipInfo.cs b/Wabbajack.CLI/Verbs/DumpZipInfo.cs index ef42b4c7..e299b245 100644 --- a/Wabbajack.CLI/Verbs/DumpZipInfo.cs +++ b/Wabbajack.CLI/Verbs/DumpZipInfo.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Logging; +using Wabbajack.CLI.Builder; using Wabbajack.Common; using Wabbajack.Compression.Zip; using Wabbajack.Downloaders; @@ -16,7 +17,7 @@ using Wabbajack.Paths.IO; namespace Wabbajack.CLI.Verbs; -public class DumpZipInfo : IVerb +public class DumpZipInfo { private readonly ILogger _logger; diff --git a/Wabbajack.CLI/Verbs/Encrypt.cs b/Wabbajack.CLI/Verbs/Encrypt.cs index eb31cb92..4f6e8ddd 100644 --- a/Wabbajack.CLI/Verbs/Encrypt.cs +++ b/Wabbajack.CLI/Verbs/Encrypt.cs @@ -3,13 +3,14 @@ using System.CommandLine.Invocation; using System.CommandLine.NamingConventionBinder; using System.Threading.Tasks; using Microsoft.Extensions.Logging; +using Wabbajack.CLI.Builder; using Wabbajack.Paths; using Wabbajack.Paths.IO; using Wabbajack.Services.OSIntegrated; namespace Wabbajack.CLI.Verbs; -public class Encrypt : IVerb +public class Encrypt { private readonly ILogger _logger; diff --git a/Wabbajack.CLI/Verbs/Extract.cs b/Wabbajack.CLI/Verbs/Extract.cs index 524bd2ab..d277c01b 100644 --- a/Wabbajack.CLI/Verbs/Extract.cs +++ b/Wabbajack.CLI/Verbs/Extract.cs @@ -5,6 +5,7 @@ using System.CommandLine.NamingConventionBinder; using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Logging; +using Wabbajack.CLI.Builder; using Wabbajack.Common; using Wabbajack.Downloaders; using Wabbajack.DTOs; @@ -13,7 +14,7 @@ using Wabbajack.Paths.IO; namespace Wabbajack.CLI.Verbs; -public class Extract : IVerb +public class Extract { private readonly ILogger _logger; diff --git a/Wabbajack.CLI/Verbs/ForceHeal.cs b/Wabbajack.CLI/Verbs/ForceHeal.cs index d43a218c..a5cc9c24 100644 --- a/Wabbajack.CLI/Verbs/ForceHeal.cs +++ b/Wabbajack.CLI/Verbs/ForceHeal.cs @@ -9,6 +9,7 @@ using System.Threading; using System.Threading.Tasks; using FluentFTP.Helpers; using Microsoft.Extensions.Logging; +using Wabbajack.CLI.Builder; using Wabbajack.Common; using Wabbajack.Compiler.PatchCache; using Wabbajack.Downloaders; @@ -25,7 +26,7 @@ using Wabbajack.VFS; namespace Wabbajack.CLI.Verbs; -public class ForceHeal : IVerb +public class ForceHeal { private readonly ILogger _logger; private readonly Client _client; diff --git a/Wabbajack.CLI/Verbs/HashFile.cs b/Wabbajack.CLI/Verbs/HashFile.cs index 2ef96eb5..fe174dca 100644 --- a/Wabbajack.CLI/Verbs/HashFile.cs +++ b/Wabbajack.CLI/Verbs/HashFile.cs @@ -5,13 +5,14 @@ using System.IO; using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Logging; +using Wabbajack.CLI.Builder; using Wabbajack.Hashing.xxHash64; using Wabbajack.Paths; using Wabbajack.Paths.IO; namespace Wabbajack.CLI.Verbs; -public class HashFile : IVerb +public class HashFile { private readonly ILogger _logger; diff --git a/Wabbajack.CLI/Verbs/HashUrlString.cs b/Wabbajack.CLI/Verbs/HashUrlString.cs index ed47e919..1e6ea32a 100644 --- a/Wabbajack.CLI/Verbs/HashUrlString.cs +++ b/Wabbajack.CLI/Verbs/HashUrlString.cs @@ -3,12 +3,13 @@ using System.CommandLine.Invocation; using System.CommandLine.NamingConventionBinder; using System.Threading.Tasks; using Microsoft.Extensions.Logging; +using Wabbajack.CLI.Builder; using Wabbajack.Hashing.xxHash64; using Wabbajack.Paths; namespace Wabbajack.CLI.Verbs; -public class HashUrlString : IVerb +public class HashUrlString { private readonly ILogger _logger; diff --git a/Wabbajack.CLI/Verbs/IVerb.cs b/Wabbajack.CLI/Verbs/IVerb.cs deleted file mode 100644 index f0f85f57..00000000 --- a/Wabbajack.CLI/Verbs/IVerb.cs +++ /dev/null @@ -1,7 +0,0 @@ -using System.CommandLine; - -namespace Wabbajack.CLI.Verbs; - -public interface IVerb -{ -} \ No newline at end of file diff --git a/Wabbajack.CLI/Verbs/Install.cs b/Wabbajack.CLI/Verbs/Install.cs index 1d208846..1e29046f 100644 --- a/Wabbajack.CLI/Verbs/Install.cs +++ b/Wabbajack.CLI/Verbs/Install.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Logging; +using Wabbajack.CLI.Builder; using Wabbajack.Downloaders; using Wabbajack.Downloaders.GameFile; using Wabbajack.DTOs; @@ -18,7 +19,7 @@ using Wabbajack.VFS; namespace Wabbajack.CLI.Verbs; -public class Install : IVerb +public class Install { private readonly ILogger _logger; private readonly Client _wjClient; diff --git a/Wabbajack.CLI/Verbs/InstallCompileInstallVerify.cs b/Wabbajack.CLI/Verbs/InstallCompileInstallVerify.cs index 86ef8670..3a36dc0d 100644 --- a/Wabbajack.CLI/Verbs/InstallCompileInstallVerify.cs +++ b/Wabbajack.CLI/Verbs/InstallCompileInstallVerify.cs @@ -8,6 +8,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Logging; +using Wabbajack.CLI.Builder; using Wabbajack.Common; using Wabbajack.Compiler; using Wabbajack.Downloaders; @@ -22,7 +23,7 @@ using Wabbajack.VFS; namespace Wabbajack.CLI.Verbs; -public class InstallCompileInstallVerify : IVerb +public class InstallCompileInstallVerify { private readonly ILogger _logger; private readonly Client _wjClient; @@ -47,7 +48,7 @@ public class InstallCompileInstallVerify : IVerb _inferencer = inferencer; } - public static VerbDefinition Definition = new VerbDefinition("install-compile-install-verify", + public static VerbDefinition Definition = new("install-compile-install-verify", "Installs a modlist, compiles it, installs it again, verifies it", new[] { new OptionDefinition(typeof(AbsolutePath), "m", "machineUrl", "Machine url(s) to download"), diff --git a/Wabbajack.CLI/Verbs/ListCreationClubContent.cs b/Wabbajack.CLI/Verbs/ListCreationClubContent.cs index eb3a528e..1146e6d2 100644 --- a/Wabbajack.CLI/Verbs/ListCreationClubContent.cs +++ b/Wabbajack.CLI/Verbs/ListCreationClubContent.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Logging; +using Wabbajack.CLI.Builder; using Wabbajack.Common; using Wabbajack.Downloaders.Bethesda; using Wabbajack.DTOs; @@ -17,7 +18,7 @@ using Wabbajack.Paths; namespace Wabbajack.CLI.Verbs; -public class ListCreationClubContent : IVerb +public class ListCreationClubContent { private readonly ILogger _logger; private readonly Client _client; diff --git a/Wabbajack.CLI/Verbs/ListGames.cs b/Wabbajack.CLI/Verbs/ListGames.cs index ec47822b..69822cf0 100644 --- a/Wabbajack.CLI/Verbs/ListGames.cs +++ b/Wabbajack.CLI/Verbs/ListGames.cs @@ -7,13 +7,14 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Logging; +using Wabbajack.CLI.Builder; using Wabbajack.Downloaders.GameFile; using Wabbajack.DTOs; using Wabbajack.Paths.IO; namespace Wabbajack.CLI.Verbs; -public class ListGames : IVerb +public class ListGames { private readonly ILogger _logger; private readonly GameLocator _locator; @@ -24,7 +25,7 @@ public class ListGames : IVerb _locator = locator; } - public static VerbDefinition Definition = new VerbDefinition("list-games", + public static VerbDefinition Definition = new("list-games", "Lists all games Wabbajack recognizes, and their installed versions/locations (if any)", Array.Empty()); internal Task Run(CancellationToken token) diff --git a/Wabbajack.CLI/Verbs/ListModlists.cs b/Wabbajack.CLI/Verbs/ListModlists.cs index 20334538..db0f9753 100644 --- a/Wabbajack.CLI/Verbs/ListModlists.cs +++ b/Wabbajack.CLI/Verbs/ListModlists.cs @@ -7,12 +7,13 @@ using System.Threading; using System.Threading.Tasks; using FluentFTP.Helpers; using Microsoft.Extensions.Logging; +using Wabbajack.CLI.Builder; using Wabbajack.DTOs; using Wabbajack.Networking.WabbajackClientApi; namespace Wabbajack.CLI.Verbs; -public class ListModlists : IVerb +public class ListModlists { private readonly ILogger _logger; private readonly Client _client; diff --git a/Wabbajack.CLI/Verbs/MirrorFile.cs b/Wabbajack.CLI/Verbs/MirrorFile.cs index 16f1c175..afcc24d1 100644 --- a/Wabbajack.CLI/Verbs/MirrorFile.cs +++ b/Wabbajack.CLI/Verbs/MirrorFile.cs @@ -3,12 +3,13 @@ using System.CommandLine.Invocation; using System.CommandLine.NamingConventionBinder; using System.Threading.Tasks; using Microsoft.Extensions.Logging; +using Wabbajack.CLI.Builder; using Wabbajack.Networking.WabbajackClientApi; using Wabbajack.Paths; namespace Wabbajack.CLI.Verbs; -public class MirrorFile : IVerb +public class MirrorFile { private readonly ILogger _logger; private readonly Client _client; diff --git a/Wabbajack.CLI/Verbs/ModlistReport.cs b/Wabbajack.CLI/Verbs/ModlistReport.cs index ac838bc9..64f31f96 100644 --- a/Wabbajack.CLI/Verbs/ModlistReport.cs +++ b/Wabbajack.CLI/Verbs/ModlistReport.cs @@ -10,6 +10,7 @@ using System.Text; using System.Threading.Tasks; using Microsoft.Extensions.Logging; using Nettle; +using Wabbajack.CLI.Builder; using Wabbajack.Common; using Wabbajack.DTOs.Directives; using Wabbajack.DTOs.JsonConverters; @@ -19,7 +20,7 @@ using Wabbajack.Paths.IO; namespace Wabbajack.CLI.Verbs; -public class ModlistReport : IVerb +public class ModlistReport { private readonly ILogger _logger; private readonly DTOSerializer _dtos; diff --git a/Wabbajack.CLI/Verbs/SteamDownloadFile.cs b/Wabbajack.CLI/Verbs/SteamDownloadFile.cs index 8fd48583..16f66e39 100644 --- a/Wabbajack.CLI/Verbs/SteamDownloadFile.cs +++ b/Wabbajack.CLI/Verbs/SteamDownloadFile.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using FluentFTP.Helpers; using Microsoft.Extensions.Logging; using SteamKit2; +using Wabbajack.CLI.Builder; using Wabbajack.DTOs; using Wabbajack.DTOs.JsonConverters; using Wabbajack.Networking.Http.Interfaces; @@ -15,7 +16,7 @@ using Wabbajack.Paths; namespace Wabbajack.CLI.Verbs; -public class SteamDownloadFile : IVerb +public class SteamDownloadFile { private readonly ILogger _logger; private readonly Client _client; @@ -35,7 +36,7 @@ public class SteamDownloadFile : IVerb _wjClient = wjClient; } - public static VerbDefinition Definition = new VerbDefinition("steam-download-file", + public static VerbDefinition Definition = new("steam-download-file", "Dumps information to the console about the given app", new[] { diff --git a/Wabbajack.CLI/Verbs/SteamDumpAppInfo.cs b/Wabbajack.CLI/Verbs/SteamDumpAppInfo.cs index 181c7bc1..4e61bd72 100644 --- a/Wabbajack.CLI/Verbs/SteamDumpAppInfo.cs +++ b/Wabbajack.CLI/Verbs/SteamDumpAppInfo.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using Microsoft.Extensions.Logging; using Newtonsoft.Json; using SteamKit2; +using Wabbajack.CLI.Builder; using Wabbajack.DTOs; using Wabbajack.DTOs.JsonConverters; using Wabbajack.Networking.Http.Interfaces; @@ -15,7 +16,7 @@ using JsonSerializer = System.Text.Json.JsonSerializer; namespace Wabbajack.CLI.Verbs; -public class SteamDumpAppInfo : IVerb +public class SteamDumpAppInfo { private readonly ILogger _logger; private readonly Client _client; @@ -33,7 +34,7 @@ public class SteamDumpAppInfo : IVerb _dtos = dtos; } - public static VerbDefinition Definition = new VerbDefinition("steam-app-dump-info", + public static VerbDefinition Definition = new("steam-app-dump-info", "Dumps information to the console about the given app", new[] { new OptionDefinition(typeof(string), "g", "game", "Wabbajack game name") diff --git a/Wabbajack.CLI/Verbs/SteamLogin.cs b/Wabbajack.CLI/Verbs/SteamLogin.cs index 1bc27af1..4fb45e36 100644 --- a/Wabbajack.CLI/Verbs/SteamLogin.cs +++ b/Wabbajack.CLI/Verbs/SteamLogin.cs @@ -4,13 +4,14 @@ using System.CommandLine.Invocation; using System.CommandLine.NamingConventionBinder; using System.Threading.Tasks; using Microsoft.Extensions.Logging; +using Wabbajack.CLI.Builder; using Wabbajack.Networking.Http.Interfaces; using Wabbajack.Networking.Steam; using Wabbajack.Paths; namespace Wabbajack.CLI.Verbs; -public class SteamLogin : IVerb +public class SteamLogin { private readonly ILogger _logger; private readonly Client _client; diff --git a/Wabbajack.CLI/Verbs/UploadToNexus.cs b/Wabbajack.CLI/Verbs/UploadToNexus.cs index 90136a93..403fa04e 100644 --- a/Wabbajack.CLI/Verbs/UploadToNexus.cs +++ b/Wabbajack.CLI/Verbs/UploadToNexus.cs @@ -1,20 +1,16 @@ -using System.CommandLine; -using System.CommandLine.Invocation; -using System.CommandLine.NamingConventionBinder; -using System.Text.Json; using System.Threading.Tasks; using Microsoft.Extensions.Logging; +using Wabbajack.CLI.Builder; using Wabbajack.Common; using Wabbajack.DTOs.JsonConverters; using Wabbajack.Networking.NexusApi; using Wabbajack.Networking.NexusApi.DTOs; using Wabbajack.Paths; -using Wabbajack.Paths.IO; namespace Wabbajack.CLI.Verbs; -public class UploadToNexus : IVerb +public class UploadToNexus { private readonly ILogger _logger; private readonly NexusApi _client; diff --git a/Wabbajack.CLI/Verbs/VFSIndex.cs b/Wabbajack.CLI/Verbs/VFSIndex.cs index baba6320..6b29fd8e 100644 --- a/Wabbajack.CLI/Verbs/VFSIndex.cs +++ b/Wabbajack.CLI/Verbs/VFSIndex.cs @@ -3,12 +3,13 @@ using System.CommandLine.Invocation; using System.CommandLine.NamingConventionBinder; using System.Threading; using System.Threading.Tasks; +using Wabbajack.CLI.Builder; using Wabbajack.Paths; using Wabbajack.VFS; namespace Wabbajack.CLI.Verbs; -public class VFSIndex : IVerb +public class VFSIndex { private readonly Context _context; @@ -17,7 +18,7 @@ public class VFSIndex : IVerb _context = context; } - public static VerbDefinition Definition = new VerbDefinition("vfs-index", + public static VerbDefinition Definition = new("vfs-index", "Index and cache the contents of a folder", new[] { new OptionDefinition(typeof(AbsolutePath), "f", "folder", "Folder to index") diff --git a/Wabbajack.CLI/Verbs/ValidateLists.cs b/Wabbajack.CLI/Verbs/ValidateLists.cs index a30572ad..643abfb6 100644 --- a/Wabbajack.CLI/Verbs/ValidateLists.cs +++ b/Wabbajack.CLI/Verbs/ValidateLists.cs @@ -12,6 +12,7 @@ using Microsoft.Extensions.Logging; using SixLabors.ImageSharp; using SixLabors.ImageSharp.Formats.Webp; using SixLabors.ImageSharp.Processing; +using Wabbajack.CLI.Builder; using Wabbajack.CLI.Services; using Wabbajack.Common; using Wabbajack.Compression.Zip; @@ -35,7 +36,7 @@ using Wabbajack.Server.Lib.TokenProviders; namespace Wabbajack.CLI.Verbs; -public class ValidateLists : IVerb +public class ValidateLists { private static readonly Uri MirrorPrefix = new("https://mirror.wabbajack.org"); private readonly WriteOnlyClient _discord; @@ -74,7 +75,7 @@ public class ValidateLists : IVerb _httpLimiter = httpLimiter; } - public static VerbDefinition Definition = new VerbDefinition("validate-lists", + public static VerbDefinition Definition = new("validate-lists", "Gets a list of modlists, validates them and exports a result list", new[] { new OptionDefinition(typeof(AbsolutePath), "r", "reports", "Location to store validation report outputs") diff --git a/Wabbajack.CLI/Wabbajack.CLI.csproj b/Wabbajack.CLI/Wabbajack.CLI.csproj index 143df91e..85becb52 100644 --- a/Wabbajack.CLI/Wabbajack.CLI.csproj +++ b/Wabbajack.CLI/Wabbajack.CLI.csproj @@ -29,6 +29,7 @@ + diff --git a/Wabbajack.sln b/Wabbajack.sln index f13b0192..40cfb3a9 100644 --- a/Wabbajack.sln +++ b/Wabbajack.sln @@ -141,6 +141,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wabbajack.App.Wpf", "Wabbaj EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wabbajack.VFS.Interfaces", "Wabbajack.VFS.Interfaces\Wabbajack.VFS.Interfaces.csproj", "{E4BDB22D-11A4-452F-8D10-D9CA9777EA22}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wabbajack.CLI.Builder", "Wabbajack.CLI.Builder\Wabbajack.CLI.Builder.csproj", "{99CD51A1-38C9-420E-9497-2C9AEAF0053C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -387,6 +389,10 @@ Global {E4BDB22D-11A4-452F-8D10-D9CA9777EA22}.Debug|Any CPU.Build.0 = Debug|Any CPU {E4BDB22D-11A4-452F-8D10-D9CA9777EA22}.Release|Any CPU.ActiveCfg = Release|Any CPU {E4BDB22D-11A4-452F-8D10-D9CA9777EA22}.Release|Any CPU.Build.0 = Release|Any CPU + {99CD51A1-38C9-420E-9497-2C9AEAF0053C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {99CD51A1-38C9-420E-9497-2C9AEAF0053C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {99CD51A1-38C9-420E-9497-2C9AEAF0053C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {99CD51A1-38C9-420E-9497-2C9AEAF0053C}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE