using TXTextControl; namespace TxFormFieldMapper; internal static class Program { private static int Main(string[] args) { var options = AppOptions.FromArgs(args); if (options.ShowUsage) { AppOptions.PrintUsage(); return 1; } if (!File.Exists(options.TemplatePath)) { Console.Error.WriteLine($"Template document not found: {options.TemplatePath}"); return 2; } if (!File.Exists(options.JsonPath)) { Console.Error.WriteLine($"JSON data source not found: {options.JsonPath}"); return 2; } var jsonFieldNames = JsonFieldExtractor.GetFieldNames(options.JsonPath); if (jsonFieldNames.Count == 0) { Console.Error.WriteLine("The JSON data source does not contain any object properties to map."); return 3; } using var textControl = new ServerTextControl(); textControl.Create(); textControl.Load(options.TemplatePath, StreamType.InternalUnicodeFormat); var mapper = new FormFieldMapper(jsonFieldNames, options.MinimumScore); var results = mapper.RenameFormFields(textControl.FormFields); textControl.Save(options.OutputPath, StreamType.InternalUnicodeFormat); foreach (var result in results) { Console.WriteLine(result.ToConsoleLine()); } Console.WriteLine(); Console.WriteLine($"Saved mapped template: {options.OutputPath}"); return 0; } }