-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgram.cs
More file actions
57 lines (44 loc) · 1.8 KB
/
Program.cs
File metadata and controls
57 lines (44 loc) · 1.8 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
55
56
57
using JsonFx.Json;
using System.IO;
namespace Preprocessor
{
internal class Program
{
private static void Main(string[] args)
{
if(args.Length != 3 && args.Length != 1)
{
System.Console.WriteLine("Usage: Parser.exe <client_map> <api_output_path> <unit_tests_output_path>");
System.Console.ReadLine();
return;
}
if(args.Length == 1)
{
args = new string[] { args[0], "Generated", "Tests" };
}
System.Console.WriteLine("Loading client map");
ClientMapping src = JsonReader.Deserialize<ClientMapping>(File.ReadAllText(args[0]));
System.Console.WriteLine("Client map loaded");
Generator.SetClientMap(src);
Generator.AddAdditionalMapping(JsonReader.Deserialize<ClientMapping>(File.ReadAllText("enums.json")));
Generator.LoadTemplate("Class_Template.cs");
Generator.LoadUTTemplate("UT_Template.cs");
Generator.LoadEnumTeplate("Enum_Template.cs");
System.Console.WriteLine("Templates loaded");
var api_files = Generator.Generate();
Utils.Empty(args[1]);
foreach (var item in api_files)
{
File.WriteAllText(Path.Combine(args[1], item.Key), Utils.Beautify(item.Value));
}
System.Console.WriteLine("API Files generated and saved");
var ut_files = Generator.GenerateUnitTests();
Utils.Empty(args[2]);
foreach (var item in ut_files)
{
File.WriteAllText(Path.Combine(args[2], item.Key), Utils.Beautify(item.Value));
}
System.Console.WriteLine("Unit tests generated and saved");
}
}
}