// 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" ); } }