From 3bd863734612dc2fe9c5c7c1405358ffb1228afb Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Wed, 15 Jan 2020 03:00:56 +0000 Subject: CTAN sync 202001150300 --- .../islandoftex/texplate/util/MessageUtils.java | 84 ++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 support/texplate/source/main/java/org/islandoftex/texplate/util/MessageUtils.java (limited to 'support/texplate/source/main/java/org/islandoftex/texplate/util/MessageUtils.java') 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" + ); + } + +} -- cgit v1.2.3