-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Program.cs
69 lines (61 loc) · 2.4 KB
/
Program.cs
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
58
59
60
61
62
63
64
65
66
67
68
69
namespace Legerity;
using System.IO;
using System.Threading.Tasks;
using CommandLine;
using Features.Generators.Android;
using Features.Generators.Windows;
using Infrastructure.Configuration;
using Infrastructure.Logging;
using Legerity.Features.Generators;
using Serilog;
public class Program
{
public static async Task Main(string[] args)
{
SerilogConfigurator.ConfigureLogging();
await Parser.Default.ParseArguments<Options>(args)
.WithNotParsed(errors =>
{
foreach (Error error in errors)
{
if (error.Tag == ErrorType.MissingRequiredOptionError)
{
Log.Error("Missing required option: {0}", error.ToString());
}
}
})
.WithParsedAsync(async options =>
{
Log.Information($"Locating {options.PlatformType:G} page files in {options.InputPath}...");
IPageObjectGenerator? pageObjectGenerator = default;
switch (options.PlatformType)
{
case PlatformType.Windows:
pageObjectGenerator = new XamlPageObjectGenerator();
break;
case PlatformType.Android:
pageObjectGenerator = new AxmlPageObjectGenerator();
break;
case PlatformType.Web:
Log.Warning("Web page object generation is not currently supported!");
break;
case PlatformType.IOS:
Log.Warning("iOS page object generation is not currently supported!");
break;
default:
Log.Warning("Cannot generate Legerity page objects for an unsupported platform type!");
return;
}
if (pageObjectGenerator == default)
{
return;
}
if (!Directory.Exists(options.OutputPath))
{
Directory.CreateDirectory(options.OutputPath);
}
await pageObjectGenerator.GenerateAsync(options.Namespace, options.InputPath, options.OutputPath);
Log.Information("Finished generating Legerity page objects!");
});
}
}