mirror of
https://github.com/SabreTools/SabreTools.Hashing.git
synced 2026-07-09 02:16:54 +00:00
Because the ordering of the enum was not guaranteed, both because of variances in .NET version and even library version, any change could mean that invisible version bumps would misalign. This attempts to fix that by converting HashType from an enum to a static class with a set of constants instead. This allows logical groupings and orderings without it affecting the values of each item.
52 lines
1.5 KiB
C#
52 lines
1.5 KiB
C#
using System;
|
|
using SabreTools.CommandLine;
|
|
using SabreTools.Hashing;
|
|
|
|
namespace Hasher.Features
|
|
{
|
|
internal sealed class ListFeature : Feature
|
|
{
|
|
#region Feature Definition
|
|
|
|
public const string DisplayName = "list";
|
|
|
|
private static readonly string[] _flags = ["--list"];
|
|
|
|
private const string _description = "List all available hashes and quit";
|
|
|
|
#endregion
|
|
|
|
public ListFeature()
|
|
: base(DisplayName, _flags, _description)
|
|
{
|
|
RequiresInputs = false;
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
/// TODO: Print all supported variants of names?
|
|
public override bool Execute()
|
|
{
|
|
Console.WriteLine("Hash Name Parameter Name ");
|
|
Console.WriteLine("--------------------------------------------------------------");
|
|
|
|
foreach (var hashType in HashType.AllHashes)
|
|
{
|
|
// Derive the parameter name
|
|
string paramName = $"{hashType}";
|
|
paramName = paramName.Replace("-", string.Empty);
|
|
paramName = paramName.Replace(" ", string.Empty);
|
|
paramName = paramName.Replace("/", "_");
|
|
paramName = paramName.Replace("\\", "_");
|
|
paramName = paramName.ToLowerInvariant();
|
|
|
|
Console.WriteLine($"{hashType.GetHashName()?.PadRight(39, ' ')} {paramName}");
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public override bool VerifyInputs() => true;
|
|
}
|
|
}
|