blob: fbb68a819e5818bdf87ef5cf7dc7e3810760af41 (
plain)
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
|
// SPDX-License-Identifier: BSD-3-Clause
package org.islandoftex.texplate.util
import java.time.LocalDate
/**
* Message helper methods.
*
* @version 1.0
* @since 1.0
*/
object MessageUtils {
// the message width
private const val WIDTH = 60
// the application version
private val VERSION = MessageUtils::class.java.`package`.implementationVersion
?: "DEVELOPMENT BUILD"
/**
* Prints a line in the terminal, without a line break.
*
* @param message The message to be printed.
*/
@JvmStatic
fun line(message: String) {
print("$message ".padEnd(WIDTH - " [FAILED]".length, '.') + " ")
}
/**
* Prints the status in the terminal.
*
* @param result The boolean value.
*/
@JvmStatic
fun status(result: Boolean) {
println(if (result) "[ DONE ]" else "[FAILED]")
}
/**
* Prints the error in the terminal.
*
* @param throwable The throwable reference.
*/
@JvmStatic
fun error(throwable: Throwable) {
println("\n" + "HOUSTON, WE'VE GOT A PROBLEM ".padEnd(WIDTH, '-') +
"\n" + throwable.message + "\n" +
"".padStart(WIDTH, '-') + "\n")
}
/**
* Prints the application logo in the terminal.
*/
fun drawLogo() {
println(
" ______ __ __ ___ __ \n" +
"/\\__ _\\ /\\ \\ /\\ \\ /\\_ \\ /\\ \\__ \n" +
"\\/_/\\ \\/ __ \\ `\\`\\/'/' _____\\//\\ \\ __ \\ \\ ,_\\ __ \n" +
" \\ \\ \\ /'__`\\`\\/ > < /\\ '__`\\\\ \\ \\ /'__`\\ \\ \\ \\/ /'__`\\ \n" +
" \\ \\ \\/\\ __/ \\/'/\\`\\\\ \\ \\L\\ \\\\_\\ \\_/\\ \\L\\.\\_\\ \\ \\_/\\ __/ \n" +
" \\ \\_\\ \\____\\ /\\_\\\\ \\_\\ \\ ,__//\\____\\ \\__/.\\_\\\\ \\__\\ \\____\\\n" +
" \\/_/\\/____/ \\/_/ \\/_/\\ \\ \\/ \\/____/\\/__/\\/_/ \\/__/\\/____/\n" +
" \\ \\_\\ \n" +
" \\/_/ \n"
)
println(
"TeXplate $VERSION, a document structure creation tool\n" +
"Copyright (c) ${LocalDate.now().year}, Island of TeX\n" +
"All rights reserved.\n"
)
}
}
|