1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
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.1";
/**
* 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"
);
}
}
|