From 7869618d5106fc15e6daf477eeecf1206e6ce078 Mon Sep 17 00:00:00 2001 From: Gravit Date: Sat, 13 Apr 2019 06:43:20 +0700 Subject: [PATCH] =?UTF-8?q?[FEATURE]=20=D0=9F=D0=BE=D0=BB=D0=BD=D0=BE?= =?UTF-8?q?=D1=81=D1=82=D1=8C=D1=8E=20=D1=80=D0=B0=D1=81=D0=BF=D1=80=D0=B5?= =?UTF-8?q?=D0=B4=D0=B5=D0=BB=D0=B5=D0=BD=D1=8B=20=D0=BA=D0=BE=D0=BC=D0=B0?= =?UTF-8?q?=D0=BD=D0=B4=D1=8B=20=D0=BF=D0=BE=20=D0=BA=D0=B0=D1=82=D0=B5?= =?UTF-8?q?=D0=B3=D0=BE=D1=80=D0=B8=D1=8F=D0=BC,=20=D0=BA=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=B4=D0=B0=20help=20=D0=B4=D0=BE=D1=81=D1=82?= =?UTF-8?q?=D1=83=D0=BF=D0=BD=D0=B0=20=D0=B8=D0=B7=20libLauncher?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../command/handler/CommandHandler.java | 39 +++++++++++-------- .../utils}/command/basic/HelpCommand.java | 17 ++++---- 2 files changed, 31 insertions(+), 25 deletions(-) rename {LaunchServer/src/main/java/ru/gravit/launchserver => libLauncher/src/main/java/ru/gravit/utils}/command/basic/HelpCommand.java (81%) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/CommandHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/CommandHandler.java index 8c610f0d..3e3675ca 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/CommandHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/CommandHandler.java @@ -12,13 +12,14 @@ import ru.gravit.launchserver.command.modules.ModulesCommand; import ru.gravit.launchserver.command.service.*; import ru.gravit.utils.command.BaseCommandCategory; +import ru.gravit.utils.command.basic.HelpCommand; public abstract class CommandHandler extends ru.gravit.utils.command.CommandHandler { public static void registerCommands(ru.gravit.utils.command.CommandHandler handler) { LaunchServer server = LaunchServer.server; BaseCommandCategory basic = new BaseCommandCategory(); // Register basic commands - basic.registerCommand("help", new HelpCommand(server)); + basic.registerCommand("help", new HelpCommand(server.commandHandler)); basic.registerCommand("version", new VersionCommand(server)); basic.registerCommand("build", new BuildCommand(server)); basic.registerCommand("stop", new StopCommand(server)); @@ -61,22 +62,28 @@ public static void registerCommands(ru.gravit.utils.command.CommandHandler handl handler.registerCategory(authCategory); //Register dump commands - handler.registerCommand("dumpSessions", new DumpSessionsCommand(server)); - handler.registerCommand("dumpEntryCache", new DumpEntryCacheCommand(server)); + BaseCommandCategory dump = new BaseCommandCategory(); + dump.registerCommand("dumpSessions", new DumpSessionsCommand(server)); + dump.registerCommand("dumpEntryCache", new DumpEntryCacheCommand(server)); + Category dumpCategory = new Category(dump,"dump", "Dump runtime data"); + handler.registerCategory(dumpCategory); //Register service commands - handler.registerCommand("reload", new ReloadCommand(server)); - handler.registerCommand("reloadAll", new ReloadAllCommand(server)); - handler.registerCommand("reloadList", new ReloadListCommand(server)); - handler.registerCommand("config", new ConfigCommand(server)); - handler.registerCommand("configHelp", new ConfigHelpCommand(server)); - handler.registerCommand("configList", new ConfigListCommand(server)); - handler.registerCommand("serverStatus", new ServerStatusCommand(server)); - handler.registerCommand("checkInstall", new CheckInstallCommand(server)); - handler.registerCommand("multi", new MultiCommand(server)); - handler.registerCommand("getModulus", new GetModulusCommand(server)); - handler.registerCommand("component", new ComponentCommand(server)); - handler.registerCommand("givePermission", new GivePermissionsCommand(server)); - handler.registerCommand("getPermissions", new GetPermissionsCommand(server)); + BaseCommandCategory service = new BaseCommandCategory(); + service.registerCommand("reload", new ReloadCommand(server)); + service.registerCommand("reloadAll", new ReloadAllCommand(server)); + service.registerCommand("reloadList", new ReloadListCommand(server)); + service.registerCommand("config", new ConfigCommand(server)); + service.registerCommand("configHelp", new ConfigHelpCommand(server)); + service.registerCommand("configList", new ConfigListCommand(server)); + service.registerCommand("serverStatus", new ServerStatusCommand(server)); + service.registerCommand("checkInstall", new CheckInstallCommand(server)); + service.registerCommand("multi", new MultiCommand(server)); + service.registerCommand("getModulus", new GetModulusCommand(server)); + service.registerCommand("component", new ComponentCommand(server)); + service.registerCommand("givePermission", new GivePermissionsCommand(server)); + service.registerCommand("getPermissions", new GetPermissionsCommand(server)); + Category serviceCategory = new Category(service,"service", "Managing LaunchServer Components"); + handler.registerCategory(serviceCategory); } } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/HelpCommand.java b/libLauncher/src/main/java/ru/gravit/utils/command/basic/HelpCommand.java similarity index 81% rename from LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/HelpCommand.java rename to libLauncher/src/main/java/ru/gravit/utils/command/basic/HelpCommand.java index 1550742f..8d82539e 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/HelpCommand.java +++ b/libLauncher/src/main/java/ru/gravit/utils/command/basic/HelpCommand.java @@ -1,9 +1,7 @@ -package ru.gravit.launchserver.command.basic; +package ru.gravit.utils.command.basic; import org.fusesource.jansi.Ansi; -import ru.gravit.launchserver.LaunchServer; import ru.gravit.utils.command.Command; -import ru.gravit.utils.command.CommandCategory; import ru.gravit.utils.command.CommandException; import ru.gravit.utils.command.CommandHandler; import ru.gravit.utils.helper.LogHelper; @@ -11,7 +9,8 @@ import java.util.Map; import java.util.Map.Entry; -public final class HelpCommand extends ru.gravit.launchserver.command.Command { +public final class HelpCommand extends Command { + private CommandHandler handler; private static void printCommand(String name, Command command) { String args = command.getArgsDescription(); //LogHelper.subInfo("%s %s - %s", name, args == null ? "[nothing]" : args, command.getUsageDescription()); @@ -36,8 +35,8 @@ private static void printCategory(String name, String description) else LogHelper.info("Category: %s", name); } - public HelpCommand(LaunchServer server) { - super(server); + public HelpCommand(CommandHandler handler) { + this.handler = handler; } @Override @@ -62,18 +61,18 @@ public void invoke(String... args) throws CommandException { } private void printCommand(String name) throws CommandException { - printCommand(name, server.commandHandler.lookup(name)); + printCommand(name, handler.lookup(name)); } private void printCommands() { - for(CommandHandler.Category category : server.commandHandler.getCategories()) + for(CommandHandler.Category category : handler.getCategories()) { printCategory(category.name, category.description); for (Entry entry : category.category.commandsMap().entrySet()) printCommand(entry.getKey(), entry.getValue()); } printCategory("Base", null); - for (Entry entry : server.commandHandler.getBaseCategory().commandsMap().entrySet()) + for (Entry entry : handler.getBaseCategory().commandsMap().entrySet()) printCommand(entry.getKey(), entry.getValue()); }