2021-12-17 23:40:45 +00:00
|
|
|
using System.CommandLine;
|
|
|
|
using System.CommandLine.Invocation;
|
2022-09-29 05:10:49 +00:00
|
|
|
using System.CommandLine.NamingConventionBinder;
|
2021-12-17 23:40:45 +00:00
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Microsoft.Extensions.Logging;
|
2022-10-14 22:08:21 +00:00
|
|
|
using Wabbajack.CLI.Builder;
|
2021-12-17 23:40:45 +00:00
|
|
|
using Wabbajack.Networking.WabbajackClientApi;
|
|
|
|
using Wabbajack.Paths;
|
|
|
|
|
|
|
|
namespace Wabbajack.CLI.Verbs;
|
|
|
|
|
2022-10-14 22:08:21 +00:00
|
|
|
public class MirrorFile
|
2021-12-17 23:40:45 +00:00
|
|
|
{
|
|
|
|
private readonly ILogger<MirrorFile> _logger;
|
|
|
|
private readonly Client _client;
|
|
|
|
|
|
|
|
public MirrorFile(ILogger<MirrorFile> logger, Client wjClient)
|
|
|
|
{
|
|
|
|
_logger = logger;
|
|
|
|
_client = wjClient;
|
|
|
|
}
|
|
|
|
|
2022-10-01 01:35:36 +00:00
|
|
|
public static VerbDefinition Definition = new("mirror-file", "Mirrors a file to the Wabbajack CDN",
|
|
|
|
new[]
|
|
|
|
{
|
|
|
|
new OptionDefinition(typeof(AbsolutePath), "i", "input", "File to Mirror")
|
|
|
|
});
|
2021-12-17 23:40:45 +00:00
|
|
|
public async Task<int> Run(AbsolutePath input)
|
|
|
|
{
|
|
|
|
_logger.LogInformation("Generating File Definition for {Name}", input.FileName);
|
|
|
|
var definition = await _client.GenerateFileDefinition(input);
|
|
|
|
await _client.UploadMirror(definition, input);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|