Improved the Command Line Util
This commit is contained in:
+76
-21
@@ -5,57 +5,108 @@ 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: Update.main,
|
||||
dDoc: "This command runs through all libraries in libs.xml, and install them.\nIf they're already installed, they will be updated."
|
||||
dDoc: [
|
||||
"Usage: setup",
|
||||
"",
|
||||
"This command runs through all libraries in libs.xml, and install them.",
|
||||
"If they're already installed, they will be updated.",
|
||||
"",
|
||||
"--all : Reinstall all libraries.",
|
||||
"--no-vscheck : Don't check if Visual Studio is installed.",
|
||||
"-s | --silent | --silent-progress : Don't show download progress."
|
||||
].join("\n")
|
||||
},
|
||||
{
|
||||
names: ["help", null],
|
||||
doc: "Shows help. Pass a command name to get additional help.",
|
||||
func: help,
|
||||
dDoc: "Usage: help <cmd>\n\nFor example, use \"cne help test\" to get additional help on the test command."
|
||||
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>\n" +
|
||||
"\nThis will create a quick debug build binded to the source then run it, which means:" +
|
||||
"\n- The assets WON'T be copied over - Assets will be read from the game's source." +
|
||||
"\n- This build WON'T be ready for release - Running anywhere else than in the bin folder will result in a crash from missing assets" +
|
||||
"\n- This build will also use the mods folder from the source directory." +
|
||||
"\n\nIf you want a full build which contains all assets, run \"cne release\" or \"cne test-release\"" +
|
||||
"\nAdditional arguments will be sent to the lime compiler."
|
||||
dDoc: [
|
||||
"Usage: test <optional args>",
|
||||
"",
|
||||
"This will create a quick debug build binded 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."
|
||||
].join("\n")
|
||||
},
|
||||
{
|
||||
names: ["build"],
|
||||
doc: "Creates a non final test build, without running it.",
|
||||
func: Compiler.build,
|
||||
dDoc: "Usage: build <optional arguments>\n" +
|
||||
"\nThis will create a quick debug build binded to the source then run it, which means:" +
|
||||
"\n- The assets WON'T be copied over - Assets will be read from the game's source." +
|
||||
"\n- This build WON'T be ready for release - Running anywhere else than in the bin folder will result in a crash from missing assets" +
|
||||
"\n- This build will also use the mods folder from the source directory." +
|
||||
"\n\nIf you want a full build which contains all assets, run \"cne release\" or \"cne test-release\"" +
|
||||
"\nAdditional arguments will be sent to the lime compiler."
|
||||
dDoc: [
|
||||
"Usage: build <optional arguments>",
|
||||
"",
|
||||
"This will create a quick debug build binded 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."
|
||||
].join("\n")
|
||||
},
|
||||
{
|
||||
names: ["release"],
|
||||
doc: "Creates a final non debug build, containing all assets.",
|
||||
func: Compiler.release,
|
||||
dDoc: "Usage: release <optional arguments>\n" +
|
||||
"\nThis will create 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."
|
||||
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."
|
||||
].join("\n")
|
||||
},
|
||||
{
|
||||
names: ["test-release"],
|
||||
doc: "Creates a final non debug build, containing all assets.",
|
||||
func: Compiler.testRelease,
|
||||
dDoc: "Usage: release <optional arguments>\n" +
|
||||
"\nThis 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."
|
||||
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."
|
||||
].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 arent supported.",
|
||||
"",
|
||||
"-O | --no-old : No Old file will be created.",
|
||||
].join("\n")
|
||||
}
|
||||
];
|
||||
}
|
||||
@@ -66,8 +117,12 @@ class Main {
|
||||
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;
|
||||
}
|
||||
@@ -90,7 +145,7 @@ class Main {
|
||||
return;
|
||||
}
|
||||
|
||||
Sys.println('${matchingCommand.names.join(", ")}');
|
||||
Sys.println('Command: ${matchingCommand.names.filter(v->v != null).join(", ")}');
|
||||
Sys.println("---");
|
||||
Sys.println(matchingCommand.dDoc);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user