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
use super::*;

pub fn format_info<T: fmt::Display>(desc: &str, info: T, add_info_string: bool) -> String {
    let mut desc = desc.trim().trim_end_matches(':').to_string();
    if GLOBAL_TIMECAT_STATE.is_in_uci_mode() {
        desc = desc.to_lowercase();
    }
    desc = desc.colorize(INFO_MESSAGE_STYLE);
    if GLOBAL_TIMECAT_STATE.is_in_console_mode() {
        format!("{desc}: {info}")
    } else {
        let mut formatted_info = format!("{desc} {info}",);
        if add_info_string {
            formatted_info = "info string ".colorize(INFO_MESSAGE_STYLE) + &formatted_info
        }
        formatted_info
    }
}

pub fn force_println_info<T: fmt::Display>(desc: &str, info: T) {
    println_wasm!("{}", format_info(desc, info, true));
}

#[inline]
pub fn println_info<T: fmt::Display>(desc: &str, info: T) {
    if GLOBAL_TIMECAT_STATE.is_in_debug_mode() {
        force_println_info(desc, info);
    }
}

#[inline]
pub fn get_engine_version() -> String {
    format!("{ENGINE_NAME} v{ENGINE_VERSION}")
}

pub fn print_engine_version() {
    println_wasm!("{}", get_engine_version().colorize(SUCCESS_MESSAGE_STYLE));
}

pub fn print_cache_table_info(
    name: &str,
    table_len: impl fmt::Display,
    table_size: impl fmt::Display,
) {
    let mut to_print = format!(
        "{name} initialization complete with {table_len} entries taking {table_size} space."
    );
    if GLOBAL_TIMECAT_STATE.is_in_uci_mode() {
        to_print = "info string ".to_string() + to_print.trim();
    }
    println_wasm!("{}", to_print.colorize(INFO_MESSAGE_STYLE));
}