2 * Copyright (c) 2018-2019. Developed by Hedgecode.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.hedgecode.chess;
19 import java.time.LocalDateTime;
20 import java.util.Calendar;
23 * ChessHog utility class for working with console.
25 * @author Dmitry Samoshin aka gotty
27 public class ChessHogConsole {
29 private static final String[] ASCII_LOGO = {
31 " | | _|_ _| |___ ___ ___ ___ _| |___ ",
32 " | | -_| . | . | -_| _| . | . | -_| ",
33 " | |___|___|_ |___|___|___|___|___| ",
34 " |___|___| |___| _ _ ",
35 " ___| |_ ___ ___ ___| |_ ___ ___ ",
36 " | _| | -_|_ -|_ -| | . | . | ",
37 " |___|_|_|___|___|___|_|_|___|_ | ",
41 private static final String COPYRIGHT = "Copyright (c) Hedgecode";
43 private static boolean logMode = false;
45 private ChessHogConsole() {
48 public static void setLogMode(boolean isLogMode) {
52 public static void console(String message) {
55 logMode ? "[%1$tT] %2$s" : "%2$s",
57 message == null ? "" : message
62 public static void empty() {
66 public static void init() {
75 private static void asciiLogo() {
76 for (String line : ASCII_LOGO) {
81 private static void copyright() {
82 int inceptionYear = Integer.parseInt(
83 ChessHogProperties.get("chesshog.inception.year")
85 int currentYear = Calendar.getInstance().get(Calendar.YEAR);
86 String copyright = currentYear > inceptionYear
87 ? String.format("%s-%s %s", inceptionYear, currentYear, COPYRIGHT)
88 : String.format("%s %s", currentYear, COPYRIGHT);
90 alignCenter(copyright)
94 private static void version() {
98 "v. %s", ChessHogProperties.get("chesshog.version")
104 private static void os() {
108 System.getProperty("os.name"),
109 System.getProperty("os.version"),
110 System.getProperty("os.arch")
115 private static void java() {
119 System.getProperty("java.runtime.name"),
120 System.getProperty("java.runtime.version")
126 System.getProperty("java.vm.vendor"),
127 System.getProperty("java.vm.name"),
128 System.getProperty("java.vm.version")
133 private static String alignCenter(String message) {
134 int indent = (ASCII_LOGO[0].length() + message.length()) / 2;
135 return String.format(