-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
56 lines (51 loc) · 2.19 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
using CommandLine;
using IniParser.Model;
using System;
using System.Linq;
using System.Windows.Forms;
namespace GModMountManager
{
internal static class Program
{
public static Options Arguments = new Options();
public static Main mainWindow;
public static bool FirstRun = false;
public static IniData config = Config.Load();
public class Options
{
[Option('c', "console", Required = false, HelpText = "Enable console")]
public bool ConsoleEnabled { get; set; }
[Option("ignoresslerrors", Required = false, HelpText = "Ignore SSL Errors")]
public bool IgnoreSSLErrors { get; set; }
}
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
private static void Main(string[] args)
{
AppDomain.CurrentDomain.ProcessExit = new EventHandler(OnProcessExit);
Logger.Debug("Current Date and Time: {0} (UTC: {1})", DateTime.Now, DateTime.UtcNow);
var assembly = System.Reflection.Assembly.GetEntryAssembly().GetName();
Logger.Debug("{0} v{1} ({2}) with args: {3}", assembly.Name, assembly.Version, assembly.ProcessorArchitecture, string.Join(" ", args));
Parser.Default.ParseArguments<Options>(args).WithParsed(o => Arguments = o).WithNotParsed(o => Logger.Error("Unable to parse arguments: {0}", o.First().Tag));
Logger.Trace("Parsed arguments: {}", Arguments.ToJSON());
if (Arguments.ConsoleEnabled) ExternalConsole.InitConsole();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
mainWindow = new Main();
Application.Run(mainWindow);
Logger.Debug("Ended");
OnProcessExit(false, new EventArgs());
}
private static void OnProcessExit(object sender, EventArgs e)
{
Logger.Log("Exiting...");
Logger.Trace(config.ToJSON());
Config.Save(config);
ExternalConsole.Dispose();
Application.Exit();
System.Diagnostics.Process.GetCurrentProcess().Kill();
}
}
}