Files
SabreTools.Hashing/Hasher/Features/ListFeature.cs
Matt Nadareski 00a5c6c2c5 Convert HashType from enum to static class with constants
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.
2026-03-20 00:18:40 -04:00

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;
}
}