-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCommandHandler.cs
83 lines (80 loc) · 2.97 KB
/
CommandHandler.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using AppImage_Installer.Verbs;
using Mono.Unix;
using Pastel;
using ServiceClasses;
using Utilities;
namespace AppImage_Installer
{
internal class CommandHandlers
{
internal static async Task HandleInstall(InstallVerb installVerb)
{
Console.WriteLine($"Install app: {installVerb.App}");
if(File.Exists(installVerb.App))
{
if(ProgramEnvironment.AskAccept("install", "package"))
{
var ufi = new UnixFileInfo(installVerb.App);
ufi.FileAccessPermissions |= FileAccessPermissions.UserExecute;
Console.WriteLine("Begin installing app...".Pastel("#42f569"));
Integrate.InstallApp(installVerb.App);
Console.WriteLine("Done".Pastel("#42f569"));
}
else
{
Environment.Exit(0);
}
}
else
{
if(File.Exists($"{$"{Environment.GetEnvironmentVariable("HOME")}/.local/share/apps"}/repo.base"))
{
// Console.WriteLine($"Request: {args[1]}");
if(CloudRepoUtils.checkApp(CloudRepoUtils.Connection, installVerb.App))
{
await Service.InstallFromCloudRepo(installVerb.App);
}
else
{
Console.WriteLine("Maybe you made a mistake when entering, because there is no such file.".Pastel("#edea15"));
}
}
else
{
Console.WriteLine("If you want to install an application from a remote repository, start by downloading or updating the base with the \"app update\" command.".Pastel("#edea15"));
}
}
}
internal static void HandleRemove(RemoveVerb removeVerb)
{
Console.WriteLine($"Remove app: {removeVerb.App}");
if(ProgramEnvironment.AskAccept("remove", "package"))
{
Console.WriteLine("Begin removing app...".Pastel("#42f569"));
Integrate.RemoveApp(removeVerb.App);
Console.WriteLine("Done".Pastel("#42f569"));
}
else
{
Environment.Exit(0);
}
}
internal static async Task HandleSearch(SearchVerb searchVerb)
{
Console.WriteLine($"Search app: {searchVerb.App}");
Service.SearchAppInCloudRepo(searchVerb.App);
}
internal static void HandleList(ListVerb listVerb)
{
Service.ListInstalledApps();
}
internal static void HandleUpdate(UpdateVerb updateVerb)
{
Service.UpdateLocalRepoBase();
}
internal static async Task HandleUpgrade(UpgradeVerb upgradeVerb)
{
await Service.UpgradeAllApp();
}
}
}