Merge master into 306-commands-service
Conflicts: - AuthMe - CommandInitializer - ConverterCommand
This commit is contained in:
@@ -12,12 +12,15 @@ import utils.TagReplacer;
|
||||
import utils.ToolTask;
|
||||
import utils.ToolsConstants;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Scanner;
|
||||
import java.util.Set;
|
||||
|
||||
public class CommandPageCreater implements ToolTask {
|
||||
|
||||
private static final String OUTPUT_FILE = ToolsConstants.DOCS_FOLDER + "commands.md";
|
||||
|
||||
@Override
|
||||
public String getTaskName() {
|
||||
return "createCommandPage";
|
||||
@@ -30,20 +33,30 @@ public class CommandPageCreater implements ToolTask {
|
||||
+ "commands/command_entry.tpl.md");
|
||||
|
||||
StringBuilder commandsResult = new StringBuilder();
|
||||
for (CommandDescription command : baseCommands) {
|
||||
addCommandsInfo(commandsResult, baseCommands, template);
|
||||
|
||||
FileUtils.generateFileFromTemplate(
|
||||
ToolsConstants.TOOLS_SOURCE_ROOT + "commands/commands.tpl.md",
|
||||
OUTPUT_FILE,
|
||||
ANewMap.with("commands", commandsResult.toString()).build());
|
||||
System.out.println("Wrote to '" + OUTPUT_FILE + "' with " + baseCommands.size() + " base commands.");
|
||||
}
|
||||
|
||||
private static void addCommandsInfo(StringBuilder sb, Collection<CommandDescription> commands,
|
||||
final String template) {
|
||||
for (CommandDescription command : commands) {
|
||||
Map<String, String> tags = ANewMap
|
||||
.with("command", CommandUtils.constructCommandPath(command))
|
||||
.and("description", command.getDetailedDescription())
|
||||
.and("arguments", formatArguments(command.getArguments()))
|
||||
.and("permissions", formatPermissions(command.getCommandPermissions()))
|
||||
.build();
|
||||
commandsResult.append(TagReplacer.applyReplacements(template, tags));
|
||||
}
|
||||
sb.append(TagReplacer.applyReplacements(template, tags));
|
||||
|
||||
FileUtils.generateFileFromTemplate(
|
||||
ToolsConstants.TOOLS_SOURCE_ROOT + "commands/commands.tpl.md",
|
||||
ToolsConstants.DOCS_FOLDER + "commands.md",
|
||||
ANewMap.with("commands", commandsResult.toString()).build());
|
||||
if (!command.getChildren().isEmpty()) {
|
||||
addCommandsInfo(sb, command.getChildren(), template);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String formatPermissions(CommandPermissions permissions) {
|
||||
@@ -54,16 +67,16 @@ public class CommandPageCreater implements ToolTask {
|
||||
for (PermissionNode node : permissions.getPermissionNodes()) {
|
||||
result += node.getNode() + " ";
|
||||
}
|
||||
return result;
|
||||
return result.trim();
|
||||
}
|
||||
|
||||
private static String formatArguments(Iterable<CommandArgumentDescription> arguments) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (CommandArgumentDescription argument : arguments) {
|
||||
String argumentName = argument.isOptional()
|
||||
? "[" + argument.getDescription() + "]"
|
||||
: "<" + argument.getDescription() + ">";
|
||||
result.append(argumentName).append(" ");
|
||||
? "[" + argument.getName() + "]"
|
||||
: "<" + argument.getName() + ">";
|
||||
result.append(" ").append(argumentName);
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
{command}: {description} _{arguments}_
|
||||
[permissions]Permission: {permissions}[/permissions]
|
||||
- **{command}**{arguments}: {description}[permissions]
|
||||
<br />Requires `{permissions}`[/permissions]
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
## AuthMe commands
|
||||
You can use the following commands to use the functions of AuthMe:
|
||||
<!-- {gen_warning} -->
|
||||
<!-- File auto-generated on {gen_date}. See commands/commands.tpl.md -->
|
||||
|
||||
## AuthMe Commands
|
||||
You can use the following commands to use the features of AuthMe. Mandatory arguments are marked with `< >`
|
||||
brackets; optional arguments are enclosed in square brackets (`[ ]`).
|
||||
|
||||
{commands}
|
||||
|
||||
Reference in New Issue
Block a user