Merge pull request #2550 from wabbajack-tools/set-nexus-api-key

Add 'set-nexus-api-key' CLI command
This commit is contained in:
Luca 2024-05-25 19:23:06 +02:00 committed by GitHub
commit a5d9bea0ab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 71 additions and 1 deletions

View File

@ -1,7 +1,9 @@
### Changelog
#### Version - 3.6.1.0 - TBD
* Added `set-nexus-api-key` CLI command
* Added Starfield meta data
* Added Fallout New Vegas Epic Games meta data
#### Version - 3.6.0.0 - 5/25/2024
* Wabbajack now uses OAuth2 for Nexus Mods logins

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\Release\net8.0\publish\win-x64\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
<TargetFramework>net8.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>false</PublishSingleFile>
<PublishReadyToRun>false</PublishReadyToRun>
<PublishTrimmed>false</PublishTrimmed>
</PropertyGroup>
</Project>

View File

@ -43,6 +43,8 @@ CommandLineBuilder.RegisterCommand<MirrorFile>(MirrorFile.Definition, c => ((Mir
services.AddSingleton<MirrorFile>();
CommandLineBuilder.RegisterCommand<ModlistReport>(ModlistReport.Definition, c => ((ModlistReport)c).Run);
services.AddSingleton<ModlistReport>();
CommandLineBuilder.RegisterCommand<SetNexusApiKey>(SetNexusApiKey.Definition, c => ((SetNexusApiKey)c).Run);
services.AddSingleton<SetNexusApiKey>();
CommandLineBuilder.RegisterCommand<SteamDownloadFile>(SteamDownloadFile.Definition, c => ((SteamDownloadFile)c).Run);
services.AddSingleton<SteamDownloadFile>();
CommandLineBuilder.RegisterCommand<SteamDumpAppInfo>(SteamDumpAppInfo.Definition, c => ((SteamDumpAppInfo)c).Run);

View File

@ -0,0 +1,46 @@
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<NexusApiState> _tokenProvider;
private readonly ILogger<SetNexusApiKey> _logger;
public SetNexusApiKey(EncryptedJsonTokenProvider<NexusApiState> tokenProvider, ILogger<SetNexusApiKey> 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 OptionDefinition(typeof(string), "k", "key", "The Nexus API key")
]);
public async Task<int> 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;
}
}
}

View File

@ -8,12 +8,13 @@
<PackageLicenseExpression>GPL-3.0-or-later</PackageLicenseExpression>
<Version>$(VERSION)</Version>
<AssemblyName>wabbajack-cli</AssemblyName>
<PublishTrimmed>true</PublishTrimmed>
<PublishTrimmed>false</PublishTrimmed>
<TimeMode>linked</TimeMode>
<NoWarn>CS8600</NoWarn>
<NoWarn>CS8601</NoWarn>
<NoWarn>CS8618</NoWarn>
<JsonSerializerIsReflectionEnabledByDefault>true</JsonSerializerIsReflectionEnabledByDefault>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>