mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 00:34:19 +00:00
Bring back the console report tree and highlights
Rails sit in the gutter, so rows stay aligned
This commit is contained in:
1 parent
46b5c33cf1
commit
1c9f62a84c
11 files changed
+142
-118
No files matched your search
@@ -411,7 +411,7 @@ public final class IrisRuntime implements IrisPluginRuntime {
|
||||
}
|
||||
|
||||
static void success(String string) {
|
||||
Iris.msg(ChatReport.Tone.SUCCESS.marked(string));
|
||||
Iris.msg(ChatReport.Tone.SUCCESS.marked(C.IRIS + string));
|
||||
}
|
||||
|
||||
static void info(String format, Object... args) {
|
||||
@@ -868,19 +868,16 @@ public final class IrisRuntime implements IrisPluginRuntime {
|
||||
|
||||
private void report() {
|
||||
String total = seconds(TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startedAt));
|
||||
IrisLogging.notice(ChatReport.Tone.SUCCESS.marked(C.BOLD + "Enabled in " + total));
|
||||
ChatReport.Builder report = ChatReport.of(ChatReport.Tone.SUCCESS, "Enabled in " + total).unlimited();
|
||||
slowestFirst(phaseMillis, REPORTED_PHASE_MIN_MS)
|
||||
.forEach(phase -> logRow(titleCase(phase.getKey()), seconds(phase.getValue())));
|
||||
.forEach(phase -> report.entry(titleCase(phase.getKey()), seconds(phase.getValue())));
|
||||
String slowServices = slowestFirst(serviceMillis, SLOW_SERVICE_MIN_MS).stream()
|
||||
.map(service -> service.getKey() + " " + seconds(service.getValue()))
|
||||
.collect(Collectors.joining(", "));
|
||||
if (!slowServices.isEmpty()) {
|
||||
logRow("Slow Services", slowServices);
|
||||
report.entry("Slow Services", slowServices);
|
||||
}
|
||||
}
|
||||
|
||||
private static void logRow(String label, String value) {
|
||||
ConsoleLayout.labelRows(label, value).forEach(IrisLogging::notice);
|
||||
report.build().consoleLines().forEach(IrisLogging::notice);
|
||||
}
|
||||
|
||||
private static List<Map.Entry<String, Long>> slowestFirst(Map<String, Long> millisByName, long minimumMillis) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package art.arcane.iris.diagnostics.splash;
|
||||
|
||||
import art.arcane.iris.BuildConstants;
|
||||
import art.arcane.iris.localization.ConsoleLayout;
|
||||
import art.arcane.iris.localization.ChatReport;
|
||||
import art.arcane.iris.pack.BuiltInPackUpdates;
|
||||
|
||||
import java.time.LocalDate;
|
||||
@@ -113,9 +113,11 @@ public final class IrisSplashComposer {
|
||||
for (IrisSplashPackScanner.SplashPackMetadata pack : packs) {
|
||||
BuiltInPackUpdates.Update update = updates.get(pack.name());
|
||||
if (update != null && update.newerThan(pack.version())) {
|
||||
lines.add(ConsoleLayout.row("Pack " + pack.name() + " v" + update.version()
|
||||
+ " is available. You have v" + pack.version() + "."));
|
||||
lines.addAll(ConsoleLayout.nextStep("Update it", "/iris download pack=" + pack.name() + " overwrite=true"));
|
||||
lines.addAll(ChatReport.of(ChatReport.Tone.INFO, "Pack " + pack.name() + " v" + update.version()
|
||||
+ " is available. You have v" + pack.version() + ".")
|
||||
.nextStep("Update it", "/iris download pack=" + pack.name() + " overwrite=true")
|
||||
.build()
|
||||
.consoleLines());
|
||||
}
|
||||
}
|
||||
return lines;
|
||||
|
||||
@@ -11,22 +11,23 @@ public final class ChatReport {
|
||||
public static final int DEFAULT_ITEM_LIMIT = 8;
|
||||
private static final String ITEM_BULLET = " » ";
|
||||
private static final String CONTINUATION_INDENT = " ";
|
||||
private static final String CONSOLE_CONTINUATION_INDENT = " ";
|
||||
private static final String CONSOLE_COMMAND_INDENT = " ";
|
||||
private static final int CONSOLE_LABEL_WIDTH = 16;
|
||||
private static final Pattern LEGACY_COLOR = Pattern.compile("(?i)[§&][0-9A-FK-ORX]");
|
||||
|
||||
public enum Tone {
|
||||
SUCCESS(C.IRIS, ConsoleGlyphs.CHECK, C.GREEN),
|
||||
INFO(C.AQUA, "", C.RESET),
|
||||
WARNING(C.GOLD, ConsoleGlyphs.WARNING, C.YELLOW),
|
||||
ERROR(C.RED, ConsoleGlyphs.CROSS, C.RED);
|
||||
SUCCESS(C.IRIS, ConsoleGlyphs.CHECK),
|
||||
INFO(C.AQUA, ""),
|
||||
WARNING(C.GOLD, ConsoleGlyphs.WARNING),
|
||||
ERROR(C.RED, ConsoleGlyphs.CROSS);
|
||||
|
||||
private final C color;
|
||||
private final String mark;
|
||||
private final C markColor;
|
||||
|
||||
Tone(C color, String mark, C markColor) {
|
||||
Tone(C color, String mark) {
|
||||
this.color = color;
|
||||
this.mark = mark;
|
||||
this.markColor = markColor;
|
||||
}
|
||||
|
||||
/** Puts already styled console text on the gutter behind this tone's status glyph, or a blank one for info. */
|
||||
@@ -34,7 +35,7 @@ public final class ChatReport {
|
||||
if (!hasMark()) {
|
||||
return ConsoleLayout.row(styledText);
|
||||
}
|
||||
return markColor + mark + " " + C.RESET + styledText;
|
||||
return color + mark + " " + styledText;
|
||||
}
|
||||
|
||||
public boolean hasMark() {
|
||||
@@ -67,10 +68,7 @@ public final class ChatReport {
|
||||
private record NextStep(String instruction, String command) {
|
||||
}
|
||||
|
||||
/**
|
||||
* One report entry. Chat shows its styled lines; the console shows the same words on the gutter in normal
|
||||
* foreground, and a labelled entry as an aligned label row.
|
||||
*/
|
||||
/** One report entry. Chat shows its styled lines; the console draws them as a branch, a labelled entry as an aligned label row. */
|
||||
private record Entry(List<String> styledLines, String label, String value) {
|
||||
static Entry styled(List<String> styledLines) {
|
||||
return new Entry(List.copyOf(styledLines), null, null);
|
||||
@@ -80,17 +78,27 @@ public final class ChatReport {
|
||||
return new Entry(List.of(ChatReport.label(label, value)), clean(label), clean(value));
|
||||
}
|
||||
|
||||
List<String> consoleLines() {
|
||||
/** The branch's lines from column 2 on: the first sits on the branch, the rest on the trunk. */
|
||||
List<String> consoleBranch() {
|
||||
if (label != null) {
|
||||
return ConsoleLayout.labelRows(label, value);
|
||||
return labelRow();
|
||||
}
|
||||
List<String> lines = new ArrayList<>(styledLines.size());
|
||||
lines.add(ConsoleLayout.row(ConsoleLayout.withoutColors(styledLines.getFirst())));
|
||||
lines.add(styledLines.getFirst());
|
||||
for (int index = 1; index < styledLines.size(); index++) {
|
||||
lines.add(ConsoleLayout.continuation(ConsoleLayout.withoutColors(styledLines.get(index)).stripLeading()));
|
||||
lines.add(CONSOLE_CONTINUATION_INDENT + styledLines.get(index).stripLeading());
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
/** The value starts at column 18; a label too long for its column puts the value on the next line. */
|
||||
private List<String> labelRow() {
|
||||
if (label.length() < CONSOLE_LABEL_WIDTH) {
|
||||
String padding = " ".repeat(CONSOLE_LABEL_WIDTH - label.length());
|
||||
return List.of(C.GRAY + label + padding + C.IRIS + value);
|
||||
}
|
||||
return List.of(C.GRAY + label, " ".repeat(CONSOLE_LABEL_WIDTH) + C.IRIS + value);
|
||||
}
|
||||
}
|
||||
|
||||
private final Tone tone;
|
||||
@@ -188,42 +196,68 @@ public final class ChatReport {
|
||||
}
|
||||
}
|
||||
|
||||
/** The console layout: the title behind the tone's status glyph, then the body, hint and next steps on the gutter. */
|
||||
/**
|
||||
* The console layout: the title behind the tone's status glyph, then the body, hint and next steps as a tree whose
|
||||
* rails sit in the gutter, so branch text lines up with the title.
|
||||
*/
|
||||
public List<String> consoleLines() {
|
||||
List<String> lines = new ArrayList<>();
|
||||
lines.add(tone.marked(consoleTitle()));
|
||||
for (Entry entry : shownEntries()) {
|
||||
lines.addAll(entry.consoleLines());
|
||||
}
|
||||
int hidden = hiddenEntryCount();
|
||||
if (hidden > 0) {
|
||||
lines.add(ConsoleLayout.row(ReportText.moreLabel(hidden)));
|
||||
}
|
||||
if (hint != null) {
|
||||
lines.addAll(consoleHintLines());
|
||||
}
|
||||
for (NextStep step : nextSteps) {
|
||||
lines.addAll(ConsoleLayout.nextStep(step.instruction(), step.command()));
|
||||
lines.add(tone.marked(ReportText.title(tone, clean(title))));
|
||||
List<List<String>> branches = consoleBranches();
|
||||
for (int index = 0; index < branches.size(); index++) {
|
||||
addBranchLines(lines, branches.get(index), index == branches.size() - 1);
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
private String consoleTitle() {
|
||||
String plainTitle = clean(title);
|
||||
return tone == Tone.SUCCESS ? C.BOLD + plainTitle : plainTitle;
|
||||
private List<List<String>> consoleBranches() {
|
||||
List<List<String>> branches = new ArrayList<>();
|
||||
for (Entry entry : shownEntries()) {
|
||||
branches.add(entry.consoleBranch());
|
||||
}
|
||||
int hidden = hiddenEntryCount();
|
||||
if (hidden > 0) {
|
||||
branches.add(List.of(C.DARK_GRAY + ReportText.moreLabel(hidden)));
|
||||
}
|
||||
if (hint != null) {
|
||||
branches.add(consoleHintBranch());
|
||||
}
|
||||
for (NextStep step : nextSteps) {
|
||||
branches.add(nextStepBranch(step.instruction(), step.command()));
|
||||
}
|
||||
return branches;
|
||||
}
|
||||
|
||||
private void addBranchLines(List<String> lines, List<String> branch, boolean last) {
|
||||
String connector = last ? ConsoleGlyphs.LAST_BRANCH : ConsoleGlyphs.BRANCH;
|
||||
String trunk = last ? " " : ConsoleGlyphs.BAR;
|
||||
lines.add(tone.color() + connector + " " + C.GRAY + branch.getFirst());
|
||||
for (int index = 1; index < branch.size(); index++) {
|
||||
lines.add(tone.color() + trunk + " " + C.GRAY + branch.get(index));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A hint that ends in its command reads as a next step; any other hint stays one sentence. The console can't
|
||||
* click, so the step shows the full command a click would run.
|
||||
*/
|
||||
private List<String> consoleHintLines() {
|
||||
private List<String> consoleHintBranch() {
|
||||
if (hintShownCommand != null && hint.endsWith(hintShownCommand)) {
|
||||
String instruction = hint.substring(0, hint.length() - hintShownCommand.length());
|
||||
String runnable = hintClickCommand == null ? hintShownCommand : clean(hintClickCommand);
|
||||
return ConsoleLayout.nextStep(instruction, runnable);
|
||||
return nextStepBranch(instruction, runnable);
|
||||
}
|
||||
return List.of(ConsoleLayout.row(hint));
|
||||
return List.of(chatHint());
|
||||
}
|
||||
|
||||
/** An instruction ending in a colon, then the exact command on its own line so it copies as is. */
|
||||
private static List<String> nextStepBranch(String instruction, String command) {
|
||||
String trimmed = instruction.strip();
|
||||
String commandLine = CONSOLE_COMMAND_INDENT + C.IRIS + command;
|
||||
if (trimmed.isEmpty()) {
|
||||
return List.of(commandLine);
|
||||
}
|
||||
return List.of(trimmed.endsWith(":") ? trimmed : trimmed + ":", commandLine);
|
||||
}
|
||||
|
||||
private List<Entry> shownEntries() {
|
||||
|
||||
@@ -8,6 +8,8 @@ import java.util.Map;
|
||||
/** Swaps the non-ASCII glyphs Iris prints for ASCII ones when the console charset cannot encode them. */
|
||||
public final class ConsoleGlyphs {
|
||||
public static final String BAR = "\u2502";
|
||||
public static final String BRANCH = "\u251c";
|
||||
public static final String LAST_BRANCH = "\u2514";
|
||||
public static final String CHECK = "\u2713";
|
||||
public static final String WARNING = "!";
|
||||
public static final String CROSS = "\u2717";
|
||||
@@ -52,6 +54,8 @@ public final class ConsoleGlyphs {
|
||||
Map<String, String> fallbacks = new LinkedHashMap<>();
|
||||
fallbacks.put("\u00bb", ">");
|
||||
fallbacks.put(BAR, "|");
|
||||
fallbacks.put(BRANCH, "|");
|
||||
fallbacks.put(LAST_BRANCH, "`");
|
||||
fallbacks.put(CHECK, "+");
|
||||
fallbacks.put(CROSS, "x");
|
||||
fallbacks.put(ELLIPSIS, "...");
|
||||
|
||||
@@ -1,53 +1,24 @@
|
||||
package art.arcane.iris.localization;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* The console's shared row layout. Every line sits on a two-column gutter: column 0 holds a status glyph or a space
|
||||
* and content starts at column 2. Label rows put the value at column 18, and a next step puts its command on its own
|
||||
* line, indented 4, so it can be copied as is. Log records carry their own level, so the layout never emits blank lines.
|
||||
* The console's two-column gutter. Column 0 holds a status glyph, a tree rail or a space, and content starts at
|
||||
* column 2, so a report's rails, its title text and plain log lines all line up.
|
||||
*/
|
||||
public final class ConsoleLayout {
|
||||
public static final int GUTTER_WIDTH = 2;
|
||||
public static final int LABEL_WIDTH = 16;
|
||||
public static final int COMMAND_INDENT = 4;
|
||||
public static final int CONTINUATION_INDENT = 2;
|
||||
|
||||
private static final String BLANK_GUTTER = " ".repeat(GUTTER_WIDTH);
|
||||
private static final String LABEL_GAP = " ".repeat(LABEL_WIDTH);
|
||||
private static final C COMMAND_COLOR = C.AQUA;
|
||||
private static final List<String> RAILS = List.of(ConsoleGlyphs.BRANCH, ConsoleGlyphs.LAST_BRANCH, ConsoleGlyphs.BAR);
|
||||
private static final Pattern STYLING = Pattern.compile("(?i)§[0-9A-FK-ORX]|<[/#!?]?[a-z0-9_:#-]+(?::[^>]*)?>");
|
||||
private static final Pattern LEGACY_COLOR = Pattern.compile("(?i)§[0-9A-FK-ORX]");
|
||||
|
||||
private ConsoleLayout() {
|
||||
}
|
||||
|
||||
public static String row(String text) {
|
||||
return BLANK_GUTTER + C.RESET + text;
|
||||
}
|
||||
|
||||
public static String continuation(String text) {
|
||||
return row(" ".repeat(CONTINUATION_INDENT) + text);
|
||||
}
|
||||
|
||||
public static List<String> labelRows(String label, String value) {
|
||||
if (label.length() < LABEL_WIDTH) {
|
||||
return List.of(row(padRight(label, LABEL_WIDTH) + value));
|
||||
}
|
||||
return List.of(row(label), row(LABEL_GAP + value));
|
||||
}
|
||||
|
||||
/** An instruction ending in a colon, then the exact command on its own line; an empty instruction leaves only the command. */
|
||||
public static List<String> nextStep(String instruction, String command) {
|
||||
List<String> lines = new ArrayList<>(2);
|
||||
String trimmed = instruction == null ? "" : instruction.strip();
|
||||
if (!trimmed.isEmpty()) {
|
||||
lines.add(row(trimmed.endsWith(":") ? trimmed : trimmed + ":"));
|
||||
}
|
||||
lines.add(row(" ".repeat(COMMAND_INDENT - GUTTER_WIDTH) + COMMAND_COLOR + command));
|
||||
return lines;
|
||||
return BLANK_GUTTER + text;
|
||||
}
|
||||
|
||||
/** Puts a log line on the gutter, marked for its tone, unless it already starts with a gutter of its own. */
|
||||
@@ -58,15 +29,16 @@ public final class ConsoleLayout {
|
||||
return tone.marked(styledLine);
|
||||
}
|
||||
|
||||
public static String withoutColors(String styledText) {
|
||||
return styledText == null ? "" : LEGACY_COLOR.matcher(styledText).replaceAll("");
|
||||
}
|
||||
|
||||
static boolean hasGutter(String styledLine) {
|
||||
String plain = STYLING.matcher(styledLine).replaceAll("");
|
||||
if (plain.isBlank() || plain.startsWith(BLANK_GUTTER)) {
|
||||
return true;
|
||||
}
|
||||
for (String rail : RAILS) {
|
||||
if (plain.startsWith(rail + " ")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for (ChatReport.Tone tone : ChatReport.Tone.values()) {
|
||||
if (tone.hasMark() && plain.startsWith(tone.mark() + " ")) {
|
||||
return true;
|
||||
@@ -74,8 +46,4 @@ public final class ConsoleLayout {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static String padRight(String text, int width) {
|
||||
return text + " ".repeat(Math.max(0, width - text.length()));
|
||||
}
|
||||
}
|
||||
@@ -325,7 +325,7 @@ public class VolmitSender implements CommandSender {
|
||||
}
|
||||
|
||||
private void sendToned(ChatReport.Tone tone, String message) {
|
||||
sendMessage(isPlayer() ? tone.paint(message) : tone.marked(ChatReport.clean(message)));
|
||||
sendMessage(isPlayer() ? tone.paint(message) : tone.marked(tone.paint(message)));
|
||||
}
|
||||
|
||||
public void sendReport(ChatReport report) {
|
||||
|
||||
@@ -3,7 +3,6 @@ package art.arcane.iris.world.safeguard;
|
||||
import art.arcane.iris.world.IrisStartupValidation;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
import art.arcane.iris.localization.ChatReport;
|
||||
import art.arcane.iris.localization.ConsoleLayout;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -128,7 +127,7 @@ public final class IrisSafeguard {
|
||||
|
||||
public static void printFooter() {
|
||||
switch (mode) {
|
||||
case STABLE -> IrisLogging.info(ChatReport.Tone.SUCCESS.marked("Stable, no conflicts"));
|
||||
case STABLE -> IrisLogging.info(ChatReport.Tone.SUCCESS.marked(ChatReport.Tone.SUCCESS.paint("Stable, no conflicts")));
|
||||
case WARNING -> warning();
|
||||
case UNSTABLE -> unstable();
|
||||
}
|
||||
@@ -142,14 +141,18 @@ public final class IrisSafeguard {
|
||||
// A log record carries a level, so a blank record renders as an empty [WARN] line and a rule of
|
||||
// dashes renders as a [SEVERE] one. Spacing belongs to a console, not to the server log.
|
||||
private static void warning() {
|
||||
IrisLogging.warn(ChatReport.Tone.WARNING.marked("Iris is running in Warning Mode"));
|
||||
IrisLogging.warn(ConsoleLayout.row("Some startup checks need attention. The warnings above suggest fixes."));
|
||||
IrisLogging.warn(ConsoleLayout.row("Startup continues."));
|
||||
ChatReport.of(ChatReport.Tone.WARNING, "Iris is running in Warning Mode")
|
||||
.item("Some startup checks need attention. The warnings above suggest fixes.")
|
||||
.item("Startup continues.")
|
||||
.build()
|
||||
.log();
|
||||
}
|
||||
|
||||
private static void unstable() {
|
||||
IrisLogging.error(ChatReport.Tone.ERROR.marked("Iris is running in Danger Mode"));
|
||||
IrisLogging.error(ConsoleLayout.row("Critical startup checks failed. Fix the errors above."));
|
||||
ChatReport.of(ChatReport.Tone.ERROR, "Iris is running in Danger Mode")
|
||||
.item("Critical startup checks failed. Fix the errors above.")
|
||||
.build()
|
||||
.log();
|
||||
// No startup sleep: blocking the boot thread protected nothing — world creation and
|
||||
// player admission are already gated by IrisStartupValidation.
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ public class IrisSplashComposerTest {
|
||||
new IrisSplashPackScanner.SplashPackMetadata("underworld", "1012"));
|
||||
assertEquals(List.of(
|
||||
" Pack overworld v4010 is available. You have v4009.",
|
||||
" Update it:",
|
||||
"└ Update it:",
|
||||
" /iris download pack=overworld overwrite=true"),
|
||||
IrisSplashComposer.composeUpdateLines(packs, Map.of(
|
||||
"overworld", new BuiltInPackUpdates.Update("4010"),
|
||||
|
||||
@@ -117,7 +117,7 @@ public class ChatReportTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void consoleLayoutPutsTheReportOnTheGutterWithNextStepsOnTheirOwnLines() {
|
||||
public void consoleLayoutDrawsTheBodyAsATreeWithNextStepsOnTheirOwnLines() {
|
||||
List<String> console = plainConsoleLines(ChatReport.of(ChatReport.Tone.ERROR, "Pack 'uitest' failed validation")
|
||||
.items(List.of(
|
||||
"Biome 'dev'" + REMOVED_FIELD_TAIL,
|
||||
@@ -128,18 +128,31 @@ public class ChatReportTest {
|
||||
|
||||
assertEquals(List.of(
|
||||
ConsoleGlyphs.CROSS + " Pack 'uitest' failed validation",
|
||||
" 2 biomes: caveProfile.allowWater was removed; use caveProfile.allowFluid. Cave aquifers use the dimension fluidPalette.",
|
||||
" dev, vanilla/grove",
|
||||
" Missing dimensions/ folder.",
|
||||
" See every issue:",
|
||||
ConsoleGlyphs.BRANCH + " 2 biomes: caveProfile.allowWater was removed; use caveProfile.allowFluid. Cave aquifers use the dimension fluidPalette.",
|
||||
ConsoleGlyphs.BAR + " dev, vanilla/grove",
|
||||
ConsoleGlyphs.BRANCH + " Missing dimensions/ folder.",
|
||||
ConsoleGlyphs.LAST_BRANCH + " See every issue:",
|
||||
" /iris pack validate uitest"), console);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void consoleLayoutGivesInfoTitlesABlankGutter() {
|
||||
public void consoleLayoutKeepsTheReportHighlights() {
|
||||
List<String> console = ChatReport.of(ChatReport.Tone.WARNING, "Pack 'uitest' has 1 warning")
|
||||
.item("Biome 'dev' uses create:limestone at wall.palette[0]. Install the mod.")
|
||||
.build()
|
||||
.consoleLines();
|
||||
|
||||
assertTrue(console.get(0), console.get(0).contains(C.WHITE + "'uitest'" + C.GOLD));
|
||||
assertTrue(console.get(1), console.get(1).contains(C.WHITE + "'dev'" + C.GRAY));
|
||||
assertTrue(console.get(1), console.get(1).contains(C.AQUA + "create:limestone" + C.GRAY));
|
||||
assertTrue(console.get(1), console.get(1).endsWith(C.DARK_GRAY + "Install the mod."));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void consoleLayoutKeepsInfoTitlesOnABlankGutter() {
|
||||
List<String> console = plainConsoleLines(ChatReport.of(ChatReport.Tone.INFO, "Worlds").item("world").build());
|
||||
|
||||
assertEquals(List.of(" Worlds", " world"), console);
|
||||
assertEquals(List.of(" Worlds", ConsoleGlyphs.LAST_BRANCH + " world"), console);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -151,8 +164,8 @@ public class ChatReportTest {
|
||||
|
||||
assertEquals(List.of(
|
||||
ConsoleGlyphs.CHECK + " Exported pack 'uitest'",
|
||||
" Folder exports/uitest",
|
||||
" Datapack Folder Path",
|
||||
ConsoleGlyphs.BRANCH + " Folder exports/uitest",
|
||||
ConsoleGlyphs.LAST_BRANCH + " Datapack Folder Path",
|
||||
" world/datapacks/iris"), console);
|
||||
}
|
||||
|
||||
@@ -164,7 +177,7 @@ public class ChatReportTest {
|
||||
|
||||
assertEquals(List.of(
|
||||
ConsoleGlyphs.CHECK + " Created Studio project 'uitest'",
|
||||
" Restart the server, then run:",
|
||||
ConsoleGlyphs.LAST_BRANCH + " Restart the server, then run:",
|
||||
" /iris studio open uitest"), console);
|
||||
}
|
||||
|
||||
@@ -174,16 +187,17 @@ public class ChatReportTest {
|
||||
.hint("Stop it with /iris std regen-stop", "/iris std regen-stop", "/iris std regen-stop world=w")
|
||||
.build());
|
||||
|
||||
assertEquals(List.of(" Regen started", " Stop it with:", " /iris std regen-stop world=w"), console);
|
||||
assertEquals(List.of(" Regen started", ConsoleGlyphs.LAST_BRANCH + " Stop it with:",
|
||||
" /iris std regen-stop world=w"), console);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void consoleHintWithoutACommandStaysOneRow() {
|
||||
public void consoleHintWithoutACommandStaysOneBranch() {
|
||||
List<String> console = plainConsoleLines(ChatReport.of(ChatReport.Tone.WARNING, "Regen is running")
|
||||
.hint("The console has the full refusal notice", null)
|
||||
.build());
|
||||
|
||||
assertEquals(List.of("! Regen is running", " The console has the full refusal notice"), console);
|
||||
assertEquals(List.of("! Regen is running", ConsoleGlyphs.LAST_BRANCH + " The console has the full refusal notice"), console);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -198,9 +212,11 @@ public class ChatReportTest {
|
||||
public void logLinesAlreadyOnTheGutterStayAsTheyAre() {
|
||||
String marked = ChatReport.Tone.ERROR.marked("Pack failed");
|
||||
String row = ConsoleLayout.row("Fix the errors above.");
|
||||
String branch = C.RED + ConsoleGlyphs.BRANCH + " " + C.GRAY + "Missing dimensions/ folder.";
|
||||
|
||||
assertEquals(marked, ConsoleLayout.onGutter(ChatReport.Tone.ERROR, marked));
|
||||
assertEquals(row, ConsoleLayout.onGutter(ChatReport.Tone.ERROR, row));
|
||||
assertEquals(branch, ConsoleLayout.onGutter(ChatReport.Tone.ERROR, branch));
|
||||
}
|
||||
|
||||
private static List<String> plainLines(ChatReport report) {
|
||||
|
||||
@@ -20,11 +20,11 @@ public class ConsoleGlyphsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void asciiConsoleGetsAsciiStatusGlyphs() {
|
||||
String gutter = ConsoleGlyphs.BAR + " " + ConsoleGlyphs.CHECK + " done\n" + ConsoleGlyphs.CROSS + " failed\n"
|
||||
+ ConsoleGlyphs.WARNING + " Loading" + ConsoleGlyphs.ELLIPSIS;
|
||||
public void asciiConsoleGetsAsciiGlyphsThatKeepTheGutterWidth() {
|
||||
String gutter = ConsoleGlyphs.CROSS + " failed\n" + ConsoleGlyphs.BRANCH + " item\n" + ConsoleGlyphs.BAR + " more\n"
|
||||
+ ConsoleGlyphs.LAST_BRANCH + " Loading" + ConsoleGlyphs.ELLIPSIS + "\n" + ConsoleGlyphs.CHECK + " done";
|
||||
|
||||
assertEquals("| + done\nx failed\n! Loading...", ConsoleGlyphs.forCharset(StandardCharsets.US_ASCII).fit(gutter));
|
||||
assertEquals("x failed\n| item\n| more\n` Loading...\n+ done", ConsoleGlyphs.forCharset(StandardCharsets.US_ASCII).fit(gutter));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -43,7 +43,7 @@ public class UnknownFieldReportTest {
|
||||
|
||||
assertEquals(List.of(
|
||||
"! Pack 'cavetest' has 1 unknown field. Iris ignores it.",
|
||||
" Biome 'caves' 1 file biomes/carving/volcanic.json:144"
|
||||
"└ Biome 'caves' 1 file biomes/carving/volcanic.json:144"
|
||||
), lines);
|
||||
}
|
||||
|
||||
@@ -58,8 +58,8 @@ public class UnknownFieldReportTest {
|
||||
|
||||
assertEquals(List.of(
|
||||
"! Pack 'cavetest' has 2 unknown fields. Iris ignores them.",
|
||||
" Biome 'caves' 3 files e.g. biomes/carving/deep-ravine.json:157",
|
||||
" Dimension 'caves' 1 file dimensions/cavetest.json:856"
|
||||
"├ Biome 'caves' 3 files e.g. biomes/carving/deep-ravine.json:157",
|
||||
"└ Dimension 'caves' 1 file dimensions/cavetest.json:856"
|
||||
), lines);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user