mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Merge pull request #2550 from wabbajack-tools/set-nexus-api-key
Add 'set-nexus-api-key' CLI command
This commit is contained in:
commit
a5d9bea0ab
@ -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
|
||||
|
@ -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>
|
@ -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);
|
||||
|
46
Wabbajack.CLI/Verbs/SetNexusApiKey.cs
Normal file
46
Wabbajack.CLI/Verbs/SetNexusApiKey.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user