0
0
mirror of https://github.com/sp-tarkov/assembly-tool.git synced 2025-02-13 09:10:44 -05:00

47 lines
1.5 KiB
C#
Raw Normal View History

2025-01-01 19:17:56 -05:00
using CliFx;
using CliFx.Attributes;
using CliFx.Infrastructure;
using ReCodeItLib.Models;
using ReCodeItLib.ReMapper;
using ReCodeItLib.Utils;
namespace ReCodeItCLI.Commands;
2025-01-01 22:48:18 -05:00
[Command("AutoMatch", Description = "This command will automatically try to generate a mapping object given old type and new type names.")]
2025-01-01 19:17:56 -05:00
public class AutoMatchCommand : ICommand
{
2025-01-01 22:48:18 -05:00
[CommandParameter(0, IsRequired = true, Description = "The absolute path to your assembly, folder must contain all references to be resolved.")]
2025-01-01 19:17:56 -05:00
public required string AssemblyPath { get; init; }
2025-01-02 01:21:37 -05:00
[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")]
2025-01-01 19:17:56 -05:00
public required string OldTypeName { get; init; }
2025-01-02 01:21:37 -05:00
[CommandParameter(3, IsRequired = true, Description = "The name you want the type to be renamed to")]
2025-01-01 19:17:56 -05:00
public required string NewTypeName { get; init; }
public ValueTask ExecuteAsync(IConsole console)
{
Logger.LogSync("Finding match...");
var remaps = new List<RemapModel>();
if (!string.IsNullOrEmpty(MappingsPath))
{
2025-01-01 20:07:20 -05:00
Logger.LogSync("Loaded mapping file", ConsoleColor.Green);
2025-01-01 19:17:56 -05:00
remaps.AddRange(DataProvider.LoadMappingFile(MappingsPath));
}
2025-01-01 20:07:20 -05:00
new AutoMatcher(remaps, MappingsPath)
2025-01-01 19:17:56 -05:00
.AutoMatch(AssemblyPath, OldTypeName, NewTypeName);
// Wait for log termination
Logger.Terminate();
while(Logger.IsRunning()) {}
return default;
}
}