line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojo::Console::Output; |
2
|
1
|
|
|
1
|
|
6
|
use Mojo::Base -base; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
615
|
use Term::ANSIColor; |
|
1
|
|
|
|
|
6637
|
|
|
1
|
|
|
|
|
325
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
has 'sameline' => 1; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub error { |
9
|
0
|
|
|
0
|
1
|
|
shift->wrap(@_, 'bright_red', 1); |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub info { |
13
|
0
|
|
|
0
|
1
|
|
shift->wrap(@_, 'bright_cyan'); |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub line { |
17
|
0
|
|
|
0
|
1
|
|
shift->wrap(@_); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub newline { |
21
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
my $sameline = $self->sameline; |
24
|
0
|
|
|
|
|
|
$self->sameline(0); |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
$self->wrap(@_); |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
$self->sameline($sameline); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub success { |
32
|
0
|
|
|
0
|
1
|
|
shift->wrap(@_, 'bright_green'); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub warn { |
36
|
0
|
|
|
0
|
1
|
|
shift->wrap(@_, 'bright_yellow'); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub wrap { |
40
|
0
|
|
|
0
|
1
|
|
my ($self, $message, $color, $error) = @_; |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
0
|
|
|
|
$error ||= 0; |
43
|
|
|
|
|
|
|
|
44
|
0
|
0
|
|
|
|
|
if ($error) { |
45
|
0
|
0
|
|
|
|
|
print STDERR color($color) if ($color); |
46
|
0
|
|
|
|
|
|
print STDERR $message; |
47
|
0
|
0
|
|
|
|
|
print STDERR color('reset') if ($color); |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
exit; |
50
|
|
|
|
|
|
|
} else { |
51
|
0
|
0
|
|
|
|
|
print STDOUT color($color) if ($color); |
52
|
0
|
0
|
|
|
|
|
print STDOUT sprintf("%s%s", $message, ($self->sameline ? '' : "\n")); |
53
|
0
|
0
|
|
|
|
|
print STDOUT color('reset') if ($color); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=encoding utf8 |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 NAME |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Mojo::Console::Output - write things to STDOUT / STDERR |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 METHODS |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
L inherits all methods from L and implements |
68
|
|
|
|
|
|
|
the following new ones. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head2 error |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
$self->error("The program will stop here"); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 info |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
$self->info("This is just an info message"); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 line |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
$self->line("This message will not have a new line at the end"); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 newline |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
$self->line("This message will have a new line at the end"); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 success |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
$self->success("This is just a success message"); |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 warn |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
$self->success("This is just a warning message"); |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 wrap |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
$self->wrap("Message", "color", 1/0); |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |