-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConfig.cs
65 lines (53 loc) · 1.96 KB
/
Config.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
namespace CFI;
public class Config(string? pkgmetaPath, bool useLinks, string externalDir, string addonDir, string? wowDir, bool quiet)
{
public string? PackageMetaPath { get; set; } = pkgmetaPath;
public bool UseLinks { get; init; } = useLinks;
public string ExternalDir { get; init; } = externalDir;
public string AddonDir { get; init; } = addonDir;
public string? WowDir { get; init; } = wowDir;
public bool IsWoWDirValid => !string.IsNullOrWhiteSpace(WowDir) && Directory.Exists(WowDir);
public bool Quiet { get; init; } = quiet;
public static Config FromParams(string[] args)
{
string? pkgmetaPath = null;
bool useLinks = false;
string externalDir = "./.externals";
string addonDir = "./.addon";
string? wowDir = Environment.GetEnvironmentVariable("WOW_ADDONS");
bool quiet = false;
for (int i = 0; i < args.Length; i += 1)
{
string arg = args[i];
string? nextArg = i + 1 < args.Length ? args[i + 1] : null;
switch (arg)
{
case "-p":
case "--pkgmeta":
pkgmetaPath = nextArg;
break;
case "-l":
case "--links":
useLinks = true;
break;
case "-e":
case "--external":
externalDir = nextArg ?? externalDir;
break;
case "-a":
case "--addon":
addonDir = nextArg ?? addonDir;
break;
case "-w":
case "--wow":
wowDir = nextArg;
break;
case "-q":
case "--quiet":
quiet = true;
break;
}
}
return new Config(pkgmetaPath, useLinks, externalDir, addonDir, wowDir, quiet);
}
}