-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
54 lines (43 loc) · 1.54 KB
/
Program.cs
File metadata and controls
54 lines (43 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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;
}
}