diff --git a/ReCodeItCLI/Commands/AutoMatcher.cs b/ReCodeItCLI/Commands/AutoMatcher.cs index 8fb0dca..7a2fa07 100644 --- a/ReCodeItCLI/Commands/AutoMatcher.cs +++ b/ReCodeItCLI/Commands/AutoMatcher.cs @@ -17,7 +17,7 @@ public class AutoMatchCommand : ICommand [CommandParameter(1, IsRequired = true, Description = "Path to your mapping file so it can be updated if a match is found")] public string MappingsPath { get; init; } - [CommandParameter(2, IsRequired = true, Description = "Full old type name including namespace")] + [CommandParameter(2, IsRequired = true, Description = "Full old type name including namespace `Foo.Bar` for nested classes `Foo.Bar/FooBar`")] public required string OldTypeName { get; init; } [CommandParameter(3, IsRequired = true, Description = "The name you want the type to be renamed to")] diff --git a/ReCodeItCLI/Commands/RegenerateSignature.cs b/ReCodeItCLI/Commands/RegenerateSignature.cs new file mode 100644 index 0000000..144dc4b --- /dev/null +++ b/ReCodeItCLI/Commands/RegenerateSignature.cs @@ -0,0 +1,45 @@ +using CliFx.Attributes; +using CliFx.Infrastructure; +using ReCodeItCLI.Utils; +using ReCodeItLib.ReMapper; +using ReCodeItLib.Utils; + +namespace ReCodeItCLI.Commands; + +[Command("regensig", Description = "regenerates the signature of a mapping if it is failing")] +public class RegenerateSignature : CliFx.ICommand +{ + [CommandParameter(0, IsRequired = true, Description = "The absolute path to the assembly you want to regenerate the signature for")] + public required string AssemblyPath { get; init; } + + [CommandParameter(1, IsRequired = true, Description = "The absolute path to mapping.json")] + public required string MappingPath { get; init; } + + [CommandParameter(2, IsRequired = true, Description = "Full old type name including namespace `Foo.Bar` for nested classes `Foo.Bar/FooBar`")] + public required string OldTypeName { get; init; } + + [CommandParameter(3, IsRequired = true, Description = "The new type name as listed in the mapping file")] + public required string NewTypeName { get; init; } + + + public ValueTask ExecuteAsync(IConsole console) + { + Debugger.TryWaitForDebuggerAttach(); + + DataProvider.Settings.MappingPath = MappingPath; + var remaps = DataProvider.LoadMappingFile(MappingPath); + + var target = remaps.SingleOrDefault(r => r.NewTypeName == NewTypeName); + + if (target is null) + { + Logger.LogSync("Could not find signature to regenerate", ConsoleColor.Red); + return default; + } + + new AutoMatcher(remaps, MappingPath) + .AutoMatch(AssemblyPath, OldTypeName, NewTypeName); + + return default; + } +} \ No newline at end of file