2022-01-18 03:56:29 +00:00
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Microsoft.Extensions.Logging;
|
2022-10-14 22:08:21 +00:00
|
|
|
using Wabbajack.CLI.Builder;
|
2022-01-18 03:56:29 +00:00
|
|
|
using Wabbajack.Common;
|
|
|
|
using Wabbajack.DTOs.JsonConverters;
|
|
|
|
using Wabbajack.Networking.NexusApi;
|
|
|
|
using Wabbajack.Networking.NexusApi.DTOs;
|
|
|
|
using Wabbajack.Paths;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Wabbajack.CLI.Verbs;
|
|
|
|
|
2022-10-14 22:08:21 +00:00
|
|
|
public class UploadToNexus
|
2022-01-18 03:56:29 +00:00
|
|
|
{
|
|
|
|
private readonly ILogger<UploadToNexus> _logger;
|
|
|
|
private readonly NexusApi _client;
|
|
|
|
private readonly DTOSerializer _dtos;
|
|
|
|
|
|
|
|
public UploadToNexus(ILogger<UploadToNexus> logger, NexusApi wjClient, DTOSerializer dtos)
|
|
|
|
{
|
|
|
|
_logger = logger;
|
|
|
|
_client = wjClient;
|
|
|
|
_dtos = dtos;
|
|
|
|
}
|
2022-10-01 01:35:36 +00:00
|
|
|
|
|
|
|
public static VerbDefinition Definition = new("upload-to-nexus",
|
|
|
|
"Uploads a file to the Nexus defined by the given .json definition file", new[]
|
|
|
|
{
|
|
|
|
new OptionDefinition(typeof(AbsolutePath), "d", "definition", "Definition JSON file")
|
|
|
|
});
|
|
|
|
|
2022-01-18 03:56:29 +00:00
|
|
|
|
|
|
|
public async Task<int> Run(AbsolutePath definition)
|
|
|
|
{
|
|
|
|
var d = await definition.FromJson<UploadDefinition>(_dtos);
|
|
|
|
|
|
|
|
await _client.UploadFile(d);
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|