-
-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2550 from wabbajack-tools/set-nexus-api-key
Add 'set-nexus-api-key' CLI command
- Loading branch information
Showing
5 changed files
with
71 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
Wabbajack.CLI/Properties/PublishProfiles/FolderProfile.pubxml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters