-
-
Notifications
You must be signed in to change notification settings - Fork 320
Expand file tree
/
Copy pathCommandLineHandler.hx
More file actions
90 lines (86 loc) · 2.32 KB
/
CommandLineHandler.hx
File metadata and controls
90 lines (86 loc) · 2.32 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
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
84
85
86
87
88
89
90
package funkin.backend.system;
#if sys
import sys.FileSystem;
final class CommandLineHandler {
@:noPrivateAccess
private static function __showHelpText():Void {
// Just put it all in a string array =)
final STRINGS:Array<String> = [
"--- Codename Engine Command Line Help ---",
"",
"-help | Show this help",
#if MOD_SUPPORT
"-mod [mod name] | Load a specific mod",
"-modfolder [path] | Sets the mod folder path",
"-addonsfolder [path] | Sets the addons folder path",
#end
"-nocolor | Disables colors in the terminal",
"-nogpubitmap | Forces GPU only bitmaps off",
"-nocwdfix | Turns off automatic working directory fix"
];
for (s in STRINGS) {
Sys.println(s);
}
}
public static function parseCommandLine(cmd:Array<String>) {
var i:Int = 0;
while(i < cmd.length) {
switch(cmd[i]) {
case null:
break;
case "-h" | "-help" | "help":
__showHelpText();
Sys.exit(0);
#if MOD_SUPPORT
case "-m" | "-mod" | "-currentmod":
i++;
var arg = cmd[i];
if (arg == null) {
Sys.println("[ERROR] You need to specify the mod name");
Sys.exit(1);
} else {
Main.modToLoad = arg.trim();
}
case "-modfolder":
i++;
var arg = cmd[i];
if (arg == null) {
Sys.println("[ERROR] You need to specify the mod folder path");
Sys.exit(1);
} else if (FileSystem.exists(arg)) {
funkin.backend.assets.ModsFolder.modsPath = arg;
} else {
Sys.println('[ERROR] Mod folder at "${arg}" does not exist.');
Sys.exit(1);
}
case "-addonsfolder":
i++;
var arg = cmd[i];
if (arg == null) {
Sys.println("[ERROR] You need to specify the addon folder path");
Sys.exit(1);
} else if (FileSystem.exists(arg)) {
funkin.backend.assets.ModsFolder.addonsPath = arg;
} else {
Sys.println('[ERROR] Addons folder at "${arg}" does not exist.');
Sys.exit(1);
}
#end
case "-nocolor":
Main.noTerminalColor = true;
case "-nogpubitmap":
Main.forceGPUOnlyBitmapsOff = true;
case "-nocwdfix":
Main.noCwdFix = true;
case "-livereload":
// do nothing
case "-v" | "-verbose" | "--verbose":
Main.verbose = true;
default:
Sys.println("Unknown command");
}
i++;
}
}
}
#end