2020-06-20 22:51:47 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using CommandLine;
|
|
|
|
|
using Wabbajack.Common;
|
|
|
|
|
|
|
|
|
|
namespace Wabbajack.CLI.Verbs
|
|
|
|
|
{
|
|
|
|
|
[Verb("hash-file", HelpText = "Hash a file and print the result")]
|
|
|
|
|
public class HashFile : AVerb
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
[Option('i', "input", Required = true, HelpText = "Input file name")]
|
|
|
|
|
public string Input { get; set; } = "";
|
|
|
|
|
|
|
|
|
|
protected override async Task<ExitCode> Run()
|
|
|
|
|
{
|
|
|
|
|
var abs = (AbsolutePath)Input;
|
2020-07-27 21:33:45 +00:00
|
|
|
|
var hash = await abs.FileHashAsync();
|
2021-01-09 18:44:59 +00:00
|
|
|
|
if (hash == null)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Hash is null!");
|
|
|
|
|
return ExitCode.Error;
|
|
|
|
|
}
|
|
|
|
|
Console.WriteLine($"{abs} hash: {hash} {hash.Value.ToHex()} {(long)hash}");
|
2020-06-20 22:51:47 +00:00
|
|
|
|
return ExitCode.Ok;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|