2022-06-09 12:14:21 +00:00
|
|
|
using System.CommandLine;
|
|
|
|
using System.CommandLine.Invocation;
|
2022-09-29 05:10:49 +00:00
|
|
|
using System.CommandLine.NamingConventionBinder;
|
2022-06-09 12:14:21 +00:00
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Microsoft.Extensions.Logging;
|
2022-10-14 22:08:21 +00:00
|
|
|
using Wabbajack.CLI.Builder;
|
2022-06-09 12:14:21 +00:00
|
|
|
using Wabbajack.Hashing.xxHash64;
|
|
|
|
using Wabbajack.Paths;
|
|
|
|
|
|
|
|
namespace Wabbajack.CLI.Verbs;
|
|
|
|
|
2022-10-14 22:08:21 +00:00
|
|
|
public class HashUrlString
|
2022-06-09 12:14:21 +00:00
|
|
|
{
|
|
|
|
private readonly ILogger<HashUrlString> _logger;
|
|
|
|
|
|
|
|
public HashUrlString(ILogger<HashUrlString> logger)
|
|
|
|
{
|
|
|
|
_logger = logger;
|
|
|
|
}
|
|
|
|
|
2022-10-01 01:35:36 +00:00
|
|
|
public static VerbDefinition Definition = new VerbDefinition("hash-url-string",
|
|
|
|
"Hashes a URL string and returns the hashcode as hex", new[]
|
|
|
|
{
|
|
|
|
new OptionDefinition(typeof(AbsolutePath), "u", "url", "Url string to hash")
|
|
|
|
});
|
2022-06-09 12:14:21 +00:00
|
|
|
|
|
|
|
public async Task<int> Run(string u)
|
|
|
|
{
|
|
|
|
_logger.LogInformation("Hash: {Hash}", (await u.Hash()).ToHex());
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|