-
-
Notifications
You must be signed in to change notification settings - Fork 320
Expand file tree
/
Copy pathMain.hx
More file actions
189 lines (177 loc) · 6.11 KB
/
Main.hx
File metadata and controls
189 lines (177 loc) · 6.11 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
package;
import commands.*;
class Main {
public static var commands:Array<Command> = [];
public static var curCommand:Command;
public static function initCommands() {
commands = [
{
names: ["setup"],
doc: "Setups (or updates) all libraries required for the engine.",
func: Setup.main,
dDoc: [
"Usage: setup",
"",
"This command runs through all libraries in building/libs.xml, and installs them.",
"This will generate a sum file; if the building/libs.xml file has remained unchanged,",
"then the setup process will not start. This may be avoided by using --ignore-sum.",
"",
"--all | --reinstall : Reinstall all libraries. This enforces --ignore-sum.",
"--no-vscheck : Don't check if Visual Studio is installed.",
"-s | --silent | --silent-progress : Don't show download progress.",
"-i | --ignore-sum : Ignore the library sum file, proceeding with the setup process anyway."
].join("\n")
},
{
names: ["help", null],
doc: "Shows help. Pass a command name to get additional help.",
func: help,
dDoc: [
"Usage: help <cmd>",
"",
"For example, use \"cne help test\" to get additional help on the test command."
].join("\n")
},
{
names: ["test"],
doc: "Creates a non final test build, then runs it.",
func: Compiler.test,
dDoc: [
"Usage: test <optional args>",
"",
"This will create a quick debug build connected to the source then run it, which means:",
"- The assets WON'T be copied over - Assets will be read from the game's source.",
"- This build WON'T be ready for release - Running anywhere else than in the bin folder will result in a crash from missing assets",
"- This build will also use the mods folder from the source directory.",
"",
"If you want a full build which contains all assets, run \"cne release\" or \"cne test-release\"",
"Additional arguments will be sent to the lime compiler.",
"",
"-debug : Builds a debug build.",
"-clean : Compiled files will be deleted before compiling."
].join("\n")
},
{
names: ["build"],
doc: "Creates a non final test build, without running it.",
func: Compiler.build,
dDoc: [
"Usage: build <optional arguments>",
"",
"This will create a quick debug build connected to the source then run it, which means:",
"- The assets WON'T be copied over - Assets will be read from the game's source.",
"- This build WON'T be ready for release - Running anywhere else than in the bin folder will result in a crash from missing assets",
"- This build will also use the mods folder from the source directory.",
"",
"If you want a full build which contains all assets, run \"cne release\" or \"cne test-release\"",
"Additional arguments will be sent to the lime compiler.",
"",
"-debug : Builds a debug build.",
"-clean : Compiled files will be deleted before compiling."
].join("\n")
},
{
names: ["run"],
doc: "Runs the last build that was created.",
func: Compiler.run,
dDoc: [
"Usage: run <optional arguments>",
"",
"This will run the last build that was created.",
"If the last build was a debug build, you need to pass the -debug argument to run it.",
"Additional arguments will be sent to the lime compiler."
].join("\n")
},
{
names: ["release"],
doc: "Creates a final non debug build, containing all assets.",
func: Compiler.release,
dDoc: [
"Usage: release <optional arguments>",
"",
"This will create and run a final ready-for-release build,",
"which means this build will be able to be release on websites such as GameBanana without worrying about source-dependant stuff.",
"Additional arguments will be sent to the lime compiler.",
"",
"-clean : Compiled files will be deleted before compiling."
].join("\n")
},
{
names: ["test-release"],
doc: "Creates a final non debug build, containing all assets.",
func: Compiler.testRelease,
dDoc: [
"Usage: test-release <optional arguments>",
"",
"This will create and run a final ready-for-release build,",
"which means this build will be able to be release on websites such as GameBanana without worrying about source-dependant stuff.",
"Additional arguments will be sent to the lime compiler.",
"",
"-clean : Compiled files will be deleted before compiling."
].join("\n")
},
{
names: ["optimize"],
doc: "Optimizes a JSON file.",
func: Optimizer.main,
dDoc: [
"Usage: optimize <optional arguments>",
"",
"This will optimize a JSON file, which means it will remove all unnecessary spacing from the file.",
"WARNING: Order might be lost.",
"WARNING: Comments aren't supported.",
"",
"-O | --no-old : No Old file will be created.",
].join("\n")
}
];
}
public static function main() {
initCommands();
final args = Sys.args();
var commandName = args.shift();
if (commandName != null)
commandName = commandName.toLowerCase();
else
commandName = "help";
for(c in commands) {
if (c.names.contains(commandName)) {
curCommand = c;
c.func(args);
return;
}
}
}
public static function help(args:Array<String>) {
var cmdName = args.shift();
if (cmdName != null) {
cmdName = cmdName.toLowerCase();
var matchingCommand = null;
for(c in commands) if (c.names.contains(cmdName)) {
matchingCommand = c;
break;
}
if (matchingCommand == null) {
Sys.println('help - Command named ${cmdName} not found.');
return;
}
Sys.println('Command: ${matchingCommand.names.filter(v->v != null).join(", ")}');
Sys.println("---");
Sys.println(matchingCommand.dDoc);
return;
}
// shows help
Sys.println("Codename Engine Command Line utility");
Sys.println('Available commands (${commands.length}):\n');
for(line in commands) {
if(line.names.contains(null)) line.names.remove(null);
Sys.println('${line.names.join(", ")} - ${line.doc}');
}
}
}
typedef Command = {
var names:Array<String>;
var func:Array<String>->Void;
var ?doc:String;
var ?dDoc:String;
}