From 6db4fd0737fda0988bb94a02aca34a0b7dc332e5 Mon Sep 17 00:00:00 2001
From: trawzified <55751269+tr4wzified@users.noreply.github.com>
Date: Thu, 16 May 2024 18:52:33 +0200
Subject: [PATCH 1/3] Add set-nexus-api-key command
---
.../PublishProfiles/FolderProfile.pubxml | 18 +++++++
Wabbajack.CLI/VerbRegistration.cs | 2 +
Wabbajack.CLI/Verbs/SetNexusApiKey.cs | 47 +++++++++++++++++++
Wabbajack.CLI/Wabbajack.CLI.csproj | 1 +
4 files changed, 68 insertions(+)
create mode 100644 Wabbajack.CLI/Properties/PublishProfiles/FolderProfile.pubxml
create mode 100644 Wabbajack.CLI/Verbs/SetNexusApiKey.cs
diff --git a/Wabbajack.CLI/Properties/PublishProfiles/FolderProfile.pubxml b/Wabbajack.CLI/Properties/PublishProfiles/FolderProfile.pubxml
new file mode 100644
index 00000000..57b24e02
--- /dev/null
+++ b/Wabbajack.CLI/Properties/PublishProfiles/FolderProfile.pubxml
@@ -0,0 +1,18 @@
+
+
+
+
+ Release
+ Any CPU
+ bin\Release\net8.0-windows\publish\
+ FileSystem
+ <_TargetId>Folder
+ net8.0
+ win-x64
+ true
+ false
+ false
+
+
\ No newline at end of file
diff --git a/Wabbajack.CLI/VerbRegistration.cs b/Wabbajack.CLI/VerbRegistration.cs
index 3854dce4..373b4b43 100644
--- a/Wabbajack.CLI/VerbRegistration.cs
+++ b/Wabbajack.CLI/VerbRegistration.cs
@@ -43,6 +43,8 @@ CommandLineBuilder.RegisterCommand(MirrorFile.Definition, c => ((Mir
services.AddSingleton();
CommandLineBuilder.RegisterCommand(ModlistReport.Definition, c => ((ModlistReport)c).Run);
services.AddSingleton();
+CommandLineBuilder.RegisterCommand(SetNexusApiKey.Definition, c => ((SetNexusApiKey)c).Run);
+services.AddSingleton();
CommandLineBuilder.RegisterCommand(SteamDownloadFile.Definition, c => ((SteamDownloadFile)c).Run);
services.AddSingleton();
CommandLineBuilder.RegisterCommand(SteamDumpAppInfo.Definition, c => ((SteamDumpAppInfo)c).Run);
diff --git a/Wabbajack.CLI/Verbs/SetNexusApiKey.cs b/Wabbajack.CLI/Verbs/SetNexusApiKey.cs
new file mode 100644
index 00000000..37bf618d
--- /dev/null
+++ b/Wabbajack.CLI/Verbs/SetNexusApiKey.cs
@@ -0,0 +1,47 @@
+
+using System.CommandLine;
+using System.CommandLine.Invocation;
+using System.CommandLine.NamingConventionBinder;
+using System.Threading.Tasks;
+using Microsoft.Extensions.Logging;
+using Wabbajack.CLI.Builder;
+using Wabbajack.DTOs.Logins;
+using Wabbajack.Paths;
+using Wabbajack.Paths.IO;
+using Wabbajack.Services.OSIntegrated;
+
+namespace Wabbajack.CLI.Verbs;
+
+public class SetNexusApiKey
+{
+ private readonly EncryptedJsonTokenProvider _tokenProvider;
+ private readonly ILogger _logger;
+
+ public SetNexusApiKey(EncryptedJsonTokenProvider tokenProvider, ILogger logger)
+ {
+ _tokenProvider = tokenProvider;
+ _logger = logger;
+ }
+
+ public static VerbDefinition Definition = new VerbDefinition("set-nexus-api-key",
+ "Sets the Nexus API key to the specified value",
+ new[]
+ {
+ new OptionDefinition(typeof(string), "k", "key", "The Nexus API key")
+ });
+
+ public async Task Run(string key)
+ {
+ if (string.IsNullOrEmpty(key))
+ {
+ _logger.LogInformation("Not setting Nexus API key, that looks like an empty string to me.");
+ return -1;
+ }
+ else
+ {
+ await _tokenProvider.SetToken(new NexusApiState { ApiKey = key });
+ _logger.LogInformation("Set Nexus API Key to {key}", key);
+ return 0;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Wabbajack.CLI/Wabbajack.CLI.csproj b/Wabbajack.CLI/Wabbajack.CLI.csproj
index 7fc4af60..4b656cf1 100644
--- a/Wabbajack.CLI/Wabbajack.CLI.csproj
+++ b/Wabbajack.CLI/Wabbajack.CLI.csproj
@@ -14,6 +14,7 @@
CS8601
CS8618
true
+ net8.0
From c67da65cd8152273398a6b47ed6d8f51d197c581 Mon Sep 17 00:00:00 2001
From: trawzified <55751269+tr4wzified@users.noreply.github.com>
Date: Thu, 16 May 2024 21:50:49 +0200
Subject: [PATCH 2/3] Fix trimming breaking dependency injection on publish
---
.../Properties/PublishProfiles/FolderProfile.pubxml | 3 ++-
Wabbajack.CLI/Verbs/SetNexusApiKey.cs | 5 ++---
Wabbajack.CLI/Wabbajack.CLI.csproj | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/Wabbajack.CLI/Properties/PublishProfiles/FolderProfile.pubxml b/Wabbajack.CLI/Properties/PublishProfiles/FolderProfile.pubxml
index 57b24e02..8345a901 100644
--- a/Wabbajack.CLI/Properties/PublishProfiles/FolderProfile.pubxml
+++ b/Wabbajack.CLI/Properties/PublishProfiles/FolderProfile.pubxml
@@ -6,7 +6,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
Release
Any CPU
- bin\Release\net8.0-windows\publish\
+ bin\Release\net8.0\publish\win-x64\
FileSystem
<_TargetId>Folder
net8.0
@@ -14,5 +14,6 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
true
false
false
+ false
\ No newline at end of file
diff --git a/Wabbajack.CLI/Verbs/SetNexusApiKey.cs b/Wabbajack.CLI/Verbs/SetNexusApiKey.cs
index 37bf618d..95775d7f 100644
--- a/Wabbajack.CLI/Verbs/SetNexusApiKey.cs
+++ b/Wabbajack.CLI/Verbs/SetNexusApiKey.cs
@@ -25,10 +25,9 @@ public class SetNexusApiKey
public static VerbDefinition Definition = new VerbDefinition("set-nexus-api-key",
"Sets the Nexus API key to the specified value",
- new[]
- {
+ [
new OptionDefinition(typeof(string), "k", "key", "The Nexus API key")
- });
+ ]);
public async Task Run(string key)
{
diff --git a/Wabbajack.CLI/Wabbajack.CLI.csproj b/Wabbajack.CLI/Wabbajack.CLI.csproj
index 4b656cf1..f3af5d29 100644
--- a/Wabbajack.CLI/Wabbajack.CLI.csproj
+++ b/Wabbajack.CLI/Wabbajack.CLI.csproj
@@ -8,7 +8,7 @@
GPL-3.0-or-later
$(VERSION)
wabbajack-cli
- true
+ false
linked
CS8600
CS8601
From b15a330ab82a8d47e5a8075c385eb1b935280660 Mon Sep 17 00:00:00 2001
From: Luca <52624146+EzioTheDeadPoet@users.noreply.github.com>
Date: Sat, 25 May 2024 19:11:23 +0200
Subject: [PATCH 3/3] Update CHANGELOG.md
---
CHANGELOG.md | 3 +++
1 file changed, 3 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f5cb3a43..1a38364d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,8 @@
### Changelog
+#### Version - 3.6.1.0 - TBD
+*Added `set-nexus-api-key` CLI command
+
#### Version - 3.6.0.0 - 5/25/2024
* Wabbajack now uses OAuth2 for Nexus Mods logins
* Support for DirectURL use with LL files