summaryrefslogtreecommitdiffstats
path: root/src/scripttools/debugging/scripts/commands/help.qs
diff options
context:
space:
mode:
Diffstat (limited to 'src/scripttools/debugging/scripts/commands/help.qs')
-rw-r--r--src/scripttools/debugging/scripts/commands/help.qs71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/scripttools/debugging/scripts/commands/help.qs b/src/scripttools/debugging/scripts/commands/help.qs
new file mode 100644
index 0000000..121db11
--- /dev/null
+++ b/src/scripttools/debugging/scripts/commands/help.qs
@@ -0,0 +1,71 @@
+name = "help";
+
+group = "void";
+
+shortDescription = "Print list of commands";
+
+longDescription = "";
+
+argumentTypes = [ "command-or-group-name" ];
+
+function execute() {
+ if (arguments.length == 0) {
+ var groups = getCommandGroups();
+ message("List of command categories:");
+ message("");
+ for (var name in groups) {
+ if (name == "void")
+ continue;
+ var data = groups[name];
+ message(name + " :: " + data.shortDescription);
+ }
+ message("");
+ message("Type \"help\" followed by a category name for a list of commands in that category.");
+ message("Type \"help all\" for the list of all commands.");
+ message("Type \"help\" followed by a command name for full documentation.");
+ message("Command name abbreviations are allowed if they are unambiguous.");
+ } else {
+ var arg = arguments[0];
+ if (arg == "all") {
+ var groups = getCommandGroups();
+ for (var name in groups) {
+ if (name == "void")
+ continue;
+ message("Command category: " + name);
+ message("");
+ var commands = getCommandsInGroup(name);
+ for (var i = 0; i < commands.length; ++i) {
+ var data = commands[i];
+ message(data.name + " :: " + data.shortDescription);
+ }
+ message("");
+ }
+ } else {
+ var data = findCommand(arg);
+ if (data != undefined) {
+ message(data.shortDescription + ".");
+ if (data.longDescription.length != 0)
+ message(data.longDescription);
+ if (data.aliases.length != 0)
+ message("Aliases: " + data.aliases.join(", "));
+ if (data.seeAlso.length != 0)
+ message("See also: " + data.seeAlso.join(", "));
+ } else {
+ data = getCommandGroups()[arg];
+ if (data != undefined) {
+ message(data.shortDescription + ".");
+ message("");
+ message("List of commands:");
+ message("");
+ var commands = getCommandsInGroup(arg);
+ for (var i = 0; i < commands.length; ++i) {
+ var data = commands[i];
+ message(data.name + " :: " + data.shortDescription);
+ }
+ } else {
+ message("Undefined command \"" + arg + "\". Try \"help\".");
+ }
+ }
+ }
+ }
+};