|
1 name = "help"; |
|
2 |
|
3 group = "void"; |
|
4 |
|
5 shortDescription = "Print list of commands"; |
|
6 |
|
7 longDescription = ""; |
|
8 |
|
9 argumentTypes = [ "command-or-group-name" ]; |
|
10 |
|
11 function execute() { |
|
12 if (arguments.length == 0) { |
|
13 var groups = getCommandGroups(); |
|
14 message("List of command categories:"); |
|
15 message(""); |
|
16 for (var name in groups) { |
|
17 if (name == "void") |
|
18 continue; |
|
19 var data = groups[name]; |
|
20 message(name + " :: " + data.shortDescription); |
|
21 } |
|
22 message(""); |
|
23 message("Type \"help\" followed by a category name for a list of commands in that category."); |
|
24 message("Type \"help all\" for the list of all commands."); |
|
25 message("Type \"help\" followed by a command name for full documentation."); |
|
26 message("Command name abbreviations are allowed if they are unambiguous."); |
|
27 } else { |
|
28 var arg = arguments[0]; |
|
29 if (arg == "all") { |
|
30 var groups = getCommandGroups(); |
|
31 for (var name in groups) { |
|
32 if (name == "void") |
|
33 continue; |
|
34 message("Command category: " + name); |
|
35 message(""); |
|
36 var commands = getCommandsInGroup(name); |
|
37 for (var i = 0; i < commands.length; ++i) { |
|
38 var data = commands[i]; |
|
39 message(data.name + " :: " + data.shortDescription); |
|
40 } |
|
41 message(""); |
|
42 } |
|
43 } else { |
|
44 var data = findCommand(arg); |
|
45 if (data != undefined) { |
|
46 message(data.shortDescription + "."); |
|
47 if (data.longDescription.length != 0) |
|
48 message(data.longDescription); |
|
49 if (data.aliases.length != 0) |
|
50 message("Aliases: " + data.aliases.join(", ")); |
|
51 if (data.seeAlso.length != 0) |
|
52 message("See also: " + data.seeAlso.join(", ")); |
|
53 } else { |
|
54 data = getCommandGroups()[arg]; |
|
55 if (data != undefined) { |
|
56 message(data.shortDescription + "."); |
|
57 message(""); |
|
58 message("List of commands:"); |
|
59 message(""); |
|
60 var commands = getCommandsInGroup(arg); |
|
61 for (var i = 0; i < commands.length; ++i) { |
|
62 var data = commands[i]; |
|
63 message(data.name + " :: " + data.shortDescription); |
|
64 } |
|
65 } else { |
|
66 message("Undefined command \"" + arg + "\". Try \"help\"."); |
|
67 } |
|
68 } |
|
69 } |
|
70 } |
|
71 }; |