wabbajack/Wabbajack.CLI/Verbs/HashUrlString.cs

32 lines
886 B
C#
Raw Permalink Normal View History

2022-06-09 12:14:21 +00:00
using System.CommandLine;
using System.CommandLine.Invocation;
using System.CommandLine.NamingConventionBinder;
2022-06-09 12:14:21 +00:00
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Wabbajack.CLI.Builder;
2022-06-09 12:14:21 +00:00
using Wabbajack.Hashing.xxHash64;
using Wabbajack.Paths;
namespace Wabbajack.CLI.Verbs;
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;
}
}