-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
42 lines (39 loc) · 1.61 KB
/
Program.cs
File metadata and controls
42 lines (39 loc) · 1.61 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
#nullable enable
using System;
using System.Runtime.Versioning;
namespace BrowserNavigator
{
[SupportedOSPlatform("windows")]
class Program
{
static void Main(string[] args)
{
string command = args[0];
switch (command)
{
case "-h":
case "--help":
Console.WriteLine("Commands:");
Console.WriteLine(" -h, --help - register app in registry");
Console.WriteLine(" --register - register app in registry");
Console.WriteLine(" --unregister - unregister app from registry");
break;
case "--register":
Helpers.Registry.Application.registerApplication();
break;
case "--unregister":
Helpers.Registry.Application.unregisterApplication();
break;
default:
var (browsers, defaultBrowser, _) = Helpers.Registry.Browsers.getSplittedBrowsers();
Browser? launchedBrowser = Helpers.Registry.Browsers.detectLaunchedBrowser(browsers);
Browser targetBrowser = launchedBrowser ?? defaultBrowser;
var (executable, executableArgs) = System.IO.File.Exists(command)
? targetBrowser.getFileExecutableCommand(command)
: targetBrowser.getUrlExecutableCommand(command);
System.Diagnostics.Process.Start(executable, executableArgs);
break;
}
}
}
}