-
Notifications
You must be signed in to change notification settings - Fork 1
/
Program.cs
66 lines (58 loc) · 2.63 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
using CommandLine;
using IniParser.Model;
using System;
using System.Linq;
using System.Windows.Forms;
namespace QuestHome
{
internal static class Program
{
public static Options Arguments = new Options();
public static UI.MainForm 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; }
[Option("device", Required = false, HelpText = "Connects to the device with the provided serial no")]
public string Serial { get; set; }
[Option("ip", Required = false, HelpText = "Connects to the provided ip")]
public string IP { get; set; }
[Option("port", Required = false, HelpText = "Connects to the provided port")]
public short Port { get; set; } = 5555;
}
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
private static void Main(string[] args)
{
AppDomain.CurrentDomain.ProcessExit += new EventHandler(OnProcessExit);
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));
Logger.Debug("Current Date and Time: {0} (UTC: {1})", DateTime.Now, DateTime.UtcNow);
Parser.Default.ParseArguments<Options>(args).WithParsed(o => Arguments = o).WithNotParsed(o => Logger.Error("Unable to parse arguments: {0}", o.First().Tag));
if (Arguments.ConsoleEnabled) ExternalConsole.InitConsole();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
mainWindow = new UI.MainForm();
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);
// LogReader.Dispose();
// IPC.Launcher.Dispose();
ExternalConsole.Dispose();
Application.Exit();
System.Diagnostics.Process.GetCurrentProcess().Kill();
}
}
}