[FEATURE] Разукрашеный help

This commit is contained in:
Gravit 2019-04-13 06:27:48 +07:00
parent da1fed63bd
commit 1f716f0307
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
2 changed files with 20 additions and 1 deletions

View file

@ -1,5 +1,6 @@
package ru.gravit.launchserver.command.basic; package ru.gravit.launchserver.command.basic;
import org.fusesource.jansi.Ansi;
import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.LaunchServer;
import ru.gravit.utils.command.Command; import ru.gravit.utils.command.Command;
import ru.gravit.utils.command.CommandCategory; import ru.gravit.utils.command.CommandCategory;
@ -13,7 +14,20 @@
public final class HelpCommand extends ru.gravit.launchserver.command.Command { public final class HelpCommand extends ru.gravit.launchserver.command.Command {
private static void printCommand(String name, Command command) { private static void printCommand(String name, Command command) {
String args = command.getArgsDescription(); String args = command.getArgsDescription();
LogHelper.subInfo("%s %s - %s", name, args == null ? "[nothing]" : args, command.getUsageDescription()); //LogHelper.subInfo("%s %s - %s", name, args == null ? "[nothing]" : args, command.getUsageDescription());
LogHelper.rawLog(() -> LogHelper.rawFormat(LogHelper.Level.INFO, LogHelper.getDataTime(), true) + String.format("%s %s - %s", name, args == null ? "[nothing]" : args, command.getUsageDescription()), () -> {
Ansi ansi = LogHelper.rawAnsiFormat(LogHelper.Level.INFO, LogHelper.getDataTime(), true);
ansi.fgBright(Ansi.Color.GREEN);
ansi.a(name + " ");
ansi.fgBright(Ansi.Color.CYAN);
ansi.a(args == null ? "[nothing]": args);
ansi.reset();
ansi.a(" - ");
ansi.fgBright(Ansi.Color.YELLOW);
ansi.a(command.getUsageDescription());
ansi.reset();
return ansi.toString();
});
} }
private static void printCategory(String name, String description) private static void printCategory(String name, String description)

View file

@ -160,6 +160,11 @@ public static void setDevEnabled(boolean stacktraceEnabled) {
DEV_ENABLED.set(stacktraceEnabled); DEV_ENABLED.set(stacktraceEnabled);
} }
public static String getDataTime()
{
return DATE_TIME_FORMATTER.format(LocalDateTime.now());
}
@LauncherAPI @LauncherAPI
public static void log(Level level, String message, boolean sub) { public static void log(Level level, String message, boolean sub) {
String dateTime = DATE_TIME_FORMATTER.format(LocalDateTime.now()); String dateTime = DATE_TIME_FORMATTER.format(LocalDateTime.now());