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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
use crate::terminal::Terminal;
use std::sync::Arc;
use workflow_log::style;

#[inline(always)]
pub fn tprint_impl<T>(term: T, args: &str)
where
    T: Into<Arc<Terminal>>,
{
    term.into().write(args);
}

#[inline(always)]
pub fn tprintln_impl<T>(term: T, args: &str)
where
    T: Into<Arc<Terminal>>,
{
    term.into().writeln(args);
}

#[inline(always)]
pub fn terrorln_impl<T>(term: T, args: &str)
where
    T: Into<Arc<Terminal>>,
{
    term.into()
        .writeln(style(args.to_string()).red().to_string());
}

#[inline(always)]
pub fn twarnln_impl<T>(term: T, args: &str)
where
    T: Into<Arc<Terminal>>,
{
    term.into()
        .writeln(style(args.to_string()).yellow().to_string());
}

#[inline(always)]
pub fn tpara_impl<T>(term: T, args: &str)
where
    T: Into<Arc<Terminal>>,
{
    term.into().para(args.to_string());
}

#[macro_export]
macro_rules! twarnln {
    ($target:expr) => {
        compile_error!("twarnln! macro requires at least two arguments");
    };

    ($dest:expr, $($arg:tt)*) => {
        $crate::twarnln_impl($dest.deref().clone(), &format_args!($($arg)*).to_string().as_str())
    };
}

#[macro_export]
macro_rules! terrorln {
    ($target:expr) => {
        compile_error!("terrorln! macro requires at least two arguments");
    };

    ($dest:expr, $($arg:tt)*) => {
        $crate::terrorln_impl($dest.deref().clone(), &format_args!($($arg)*).to_string().as_str())
    };
}

#[macro_export]
macro_rules! tprintln {
    ($dest:expr) => {
        $crate::tprintln_impl($dest.as_ref(), &"")
    };

    ($dest:expr, $($arg:tt)*) => {
        $crate::tprintln_impl($dest.deref().clone(), &format_args!($($arg)*).to_string().as_str())
    };
}

#[macro_export]
macro_rules! tprint {
    ($dest:expr) => {
        $crate::tprint_impl($dest.as_ref(), &"")
    };

    ($dest:expr, $($arg:tt)*) => {
        $crate::tprint_impl($dest.deref().clone(), &format_args!($($arg)*).to_string().as_str())
    };
}

#[macro_export]
macro_rules! tpara {
    ($target:expr) => {
        compile_error!("tpara! macro requires at least two arguments");
    };

    ($dest:expr, $($arg:tt)*) => {
        $crate::tpara_impl($dest.as_ref(), &format_args!($($arg)*).to_string().as_str())
    };
}