summaryrefslogtreecommitdiff
path: root/support/texplate/source/main/java/org/islandoftex/texplate/util/MessageUtils.java
diff options
context:
space:
mode:
Diffstat (limited to 'support/texplate/source/main/java/org/islandoftex/texplate/util/MessageUtils.java')
-rw-r--r--support/texplate/source/main/java/org/islandoftex/texplate/util/MessageUtils.java84
1 files changed, 84 insertions, 0 deletions
diff --git a/support/texplate/source/main/java/org/islandoftex/texplate/util/MessageUtils.java b/support/texplate/source/main/java/org/islandoftex/texplate/util/MessageUtils.java
new file mode 100644
index 0000000000..948d18d953
--- /dev/null
+++ b/support/texplate/source/main/java/org/islandoftex/texplate/util/MessageUtils.java
@@ -0,0 +1,84 @@
+// SPDX-License-Identifier: BSD-3-Clause
+package org.islandoftex.texplate.util;
+
+import org.apache.commons.text.TextStringBuilder;
+import org.apache.commons.text.WordUtils;
+
+import java.time.LocalDate;
+
+/**
+ * Message helper methods.
+ *
+ * @version 1.0
+ * @since 1.0
+ */
+public class MessageUtils {
+
+ // the message width
+ private static final int WIDTH = 60;
+
+ // the application version
+ private static final String VERSION = "1.0.0";
+
+ /**
+ * Prints a line in the terminal, without a line break.
+ *
+ * @param message The message to be printed.
+ */
+ public static void line(String message) {
+ System.out.print(new TextStringBuilder()
+ .appendFixedWidthPadRight(message.concat(" "), WIDTH - 9, '.')
+ .append(" ")
+ .toString()
+ );
+ }
+
+ /**
+ * Prints the status in the terminal.
+ *
+ * @param result The boolean value.
+ */
+ public static void status(boolean result) {
+ System.out.println(result ? "[ DONE ]" : "[FAILED]");
+ }
+
+ /**
+ * Prints the error in the terminal.
+ *
+ * @param throwable The throwable reference.
+ */
+ public static void error(Throwable throwable) {
+ System.out.println(
+ new TextStringBuilder("\n")
+ .appendFixedWidthPadRight("HOUSTON, WE'VE GOT"
+ + " A PROBLEM ", WIDTH, '-')
+ .append("\n")
+ .appendln(WordUtils.wrap(throwable.getMessage(), WIDTH))
+ .appendFixedWidthPadLeft("", WIDTH, '-')
+ .append("\n")
+ .toString());
+ }
+
+ /**
+ * Prints the application logo in the terminal.
+ */
+ public static void drawLogo() {
+ System.out.println(
+ " ______ __ __ ___ __ \n" +
+ "/\\__ _\\ /\\ \\ /\\ \\ /\\_ \\ /\\ \\__ \n" +
+ "\\/_/\\ \\/ __ \\ `\\`\\/'/' _____\\//\\ \\ __ \\ \\ ,_\\ __ \n" +
+ " \\ \\ \\ /'__`\\`\\/ > < /\\ '__`\\\\ \\ \\ /'__`\\ \\ \\ \\/ /'__`\\ \n" +
+ " \\ \\ \\/\\ __/ \\/'/\\`\\\\ \\ \\L\\ \\\\_\\ \\_/\\ \\L\\.\\_\\ \\ \\_/\\ __/ \n" +
+ " \\ \\_\\ \\____\\ /\\_\\\\ \\_\\ \\ ,__//\\____\\ \\__/.\\_\\\\ \\__\\ \\____\\\n" +
+ " \\/_/\\/____/ \\/_/ \\/_/\\ \\ \\/ \\/____/\\/__/\\/_/ \\/__/\\/____/\n" +
+ " \\ \\_\\ \n" +
+ " \\/_/ \n"
+ );
+ System.out.println(
+ "TeXplate " + VERSION + ", a document structure creation tool\n" +
+ "Copyright (c) " + LocalDate.now().getYear() + ", Island of TeX\n" +
+ "All rights reserved.\n"
+ );
+ }
+
+}