forked from BaseMC/Aves
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
86 lines (79 loc) · 2.49 KB
/
Program.cs
File metadata and controls
86 lines (79 loc) · 2.49 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
using ADB.CMD;
using CommandLine;
using CoreFrameworkBase.Crash;
using CoreFrameworkBase.Logging;
using System;
using System.Reflection;
using System.Linq;
using CoreFrameworkBase.Logging.Initalizer;
using CoreFrameworkBase.Logging.Initalizer.Impl;
/// <summary>
/// Aves Dependency Builder
/// </summary>
namespace ADB
{
/// <summary>
/// Main entry point
/// </summary>
public static class Program
{
static void Main(string[] args)
{
Run(args);
}
public static void Run(string[] args)
{
CurrentLoggerInitializer.Set(new DefaultLoggerInitializer(new DefaultLoggerInitializerConfig()));
#if !DEBUG
try
{
new CrashDetector()
{
SupplyLoggerInitalizer = () => {
InitLog(li => li.Config.WriteFile = true);
return CurrentLoggerInitializer.Current;
}
}.Init();
#endif
Parser.Default.ParseArguments<CmdOption>(args)
.WithParsed((opt) =>
{
if (opt.ShowVersion)
{
Console.WriteLine($"{Assembly.GetExecutingAssembly().GetName().Name} {Assembly.GetExecutingAssembly().GetName().Version}");
return;
}
InitLog(li => li.Config.WriteFile = opt.LogToFile);
var starter = new StartUp(opt);
starter.Start();
})
.WithNotParsed((ex) =>
{
if (ex.All(err =>
new ErrorType[]
{
ErrorType.HelpRequestedError,
ErrorType.HelpVerbRequestedError,
ErrorType.VersionRequestedError
}.Contains(err.Tag))
)
return;
InitLog();
foreach (var error in ex)
Log.Error($"Failed to parse: {error.Tag}");
});
#if !DEBUG
}
catch (Exception ex)
{
InitLog(li => li.Config.WriteFile = true);
Log.Fatal(ex);
}
#endif
}
static void InitLog(Action<DefaultLoggerInitializer> initAction = null)
{
CurrentLoggerInitializer.InitLogging(il => initAction?.Invoke((DefaultLoggerInitializer)il));
}
}
}