line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CLI::Driver::CommonRole; |
2
|
|
|
|
|
|
|
|
3
|
18
|
|
|
18
|
|
13057
|
use Modern::Perl; |
|
18
|
|
|
|
|
47
|
|
|
18
|
|
|
|
|
175
|
|
4
|
18
|
|
|
18
|
|
12410
|
use Moose::Role; |
|
18
|
|
|
|
|
100478
|
|
|
18
|
|
|
|
|
88
|
|
5
|
18
|
|
|
18
|
|
104988
|
use namespace::autoclean; |
|
18
|
|
|
|
|
48
|
|
|
18
|
|
|
|
|
185
|
|
6
|
18
|
|
|
18
|
|
1614
|
use Kavorka 'method'; |
|
18
|
|
|
|
|
60
|
|
|
18
|
|
|
|
|
182
|
|
7
|
18
|
|
|
18
|
|
12247
|
use Data::Printer alias => 'pdump'; |
|
18
|
|
|
|
|
48
|
|
|
18
|
|
|
|
|
197
|
|
8
|
18
|
|
|
18
|
|
15830
|
use Devel::Confess; |
|
18
|
|
|
|
|
159643
|
|
|
18
|
|
|
|
|
103
|
|
9
|
18
|
|
|
18
|
|
12490
|
use Capture::Tiny 'capture'; |
|
18
|
|
|
|
|
405088
|
|
|
18
|
|
|
|
|
1450
|
|
10
|
18
|
|
|
18
|
|
9722
|
use Time::localtime; |
|
18
|
|
|
|
|
102998
|
|
|
18
|
|
|
|
|
1333
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
######################################################################################### |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has verbosity => ( |
15
|
|
|
|
|
|
|
is => 'rw', |
16
|
|
|
|
|
|
|
isa => 'Num', |
17
|
|
|
|
|
|
|
lazy => 1, |
18
|
|
|
|
|
|
|
builder => '_build_verbosity', |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
######################################################################################### |
22
|
|
|
|
|
|
|
|
23
|
18
|
0
|
|
18
|
|
50140
|
method chdir (Str $dir) { |
|
18
|
0
|
|
18
|
|
47
|
|
|
18
|
0
|
|
0
|
|
3401
|
|
|
18
|
0
|
|
|
|
148
|
|
|
18
|
0
|
|
|
|
50
|
|
|
18
|
|
|
|
|
2776
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
0
|
$self->verbose3("chdir($dir)"); |
26
|
0
|
0
|
|
|
|
0
|
chdir($dir) or confess "failed to chdir to $dir: $!"; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
18
|
50
|
|
18
|
|
39533
|
method die (Str $str) { |
|
18
|
50
|
|
18
|
|
75
|
|
|
18
|
50
|
|
1
|
|
3213
|
|
|
18
|
50
|
|
|
|
165
|
|
|
18
|
50
|
|
|
|
47
|
|
|
18
|
|
|
|
|
2128
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
12
|
|
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
2
|
|
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
3
|
chomp $str; |
32
|
1
|
|
|
|
|
15
|
die "[ERROR] $str\n"; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
18
|
0
|
0
|
18
|
|
215967
|
method fatal (Str $str, Num $frames? = 0) { |
|
18
|
0
|
|
18
|
|
58
|
|
|
18
|
0
|
|
18
|
|
3639
|
|
|
18
|
0
|
|
0
|
|
148
|
|
|
18
|
0
|
|
|
|
40
|
|
|
18
|
0
|
|
|
|
2405
|
|
|
18
|
0
|
|
|
|
153
|
|
|
18
|
0
|
|
|
|
51
|
|
|
18
|
|
|
|
|
3487
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
0
|
chomp $str; |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
0
|
my $caller = ''; |
40
|
0
|
0
|
|
|
|
0
|
if ($frames) { |
41
|
0
|
|
|
|
|
0
|
$caller = sprintf " %s", ( caller($frames) )[3]; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
0
|
printf STDERR "[FATAL%s] $str\n", $caller; |
45
|
0
|
|
|
|
|
0
|
exit 1; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
18
|
0
|
|
18
|
|
40479
|
method localdatetime ($time = time) { |
|
18
|
0
|
|
0
|
|
97
|
|
|
18
|
0
|
|
|
|
4069
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
0
|
my $l = localtime($time); |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
0
|
my $str = sprintf( |
53
|
|
|
|
|
|
|
'%04d-%02d-%02d %02d:%02d:%02d', |
54
|
|
|
|
|
|
|
$l->year + 1900, |
55
|
|
|
|
|
|
|
$l->mon + 1, |
56
|
|
|
|
|
|
|
$l->mday, $l->hour, $l->min, $l->sec |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
0
|
return $str; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
18
|
50
|
|
18
|
|
143151
|
method str_to_bool (Str|Undef $str) { |
|
18
|
50
|
|
18
|
|
48
|
|
|
18
|
50
|
|
17
|
|
3515
|
|
|
18
|
50
|
|
|
|
147
|
|
|
18
|
50
|
|
|
|
51
|
|
|
18
|
|
|
|
|
4065
|
|
|
17
|
|
|
|
|
86
|
|
|
17
|
|
|
|
|
78
|
|
|
17
|
|
|
|
|
108
|
|
|
17
|
|
|
|
|
107
|
|
|
17
|
|
|
|
|
51
|
|
|
17
|
|
|
|
|
143
|
|
|
17
|
|
|
|
|
41
|
|
63
|
|
|
|
|
|
|
|
64
|
17
|
50
|
|
|
|
90
|
if (defined $str) { |
65
|
17
|
0
|
33
|
|
|
163
|
if ($str =~ /^true$/i or $str =~ /^yes$/i or $str eq '1') { |
|
|
|
33
|
|
|
|
|
66
|
17
|
|
|
|
|
89
|
return 1; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
return 0; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
method system (Str :$cmd, |
74
|
|
|
|
|
|
|
Bool :$confess_on_err = 1, |
75
|
18
|
0
|
0
|
18
|
|
101780
|
Bool :$capture = 0) { |
|
18
|
0
|
0
|
18
|
|
64
|
|
|
18
|
0
|
|
18
|
|
2378
|
|
|
18
|
0
|
|
18
|
|
164
|
|
|
18
|
0
|
|
18
|
|
71
|
|
|
18
|
0
|
|
18
|
|
1027
|
|
|
18
|
0
|
|
18
|
|
12589
|
|
|
18
|
0
|
|
0
|
|
76037
|
|
|
18
|
0
|
|
|
|
134
|
|
|
18
|
0
|
|
|
|
2442
|
|
|
18
|
|
|
|
|
66
|
|
|
18
|
|
|
|
|
6642
|
|
|
18
|
|
|
|
|
152
|
|
|
18
|
|
|
|
|
51
|
|
|
18
|
|
|
|
|
2616
|
|
|
18
|
|
|
|
|
146
|
|
|
18
|
|
|
|
|
50
|
|
|
18
|
|
|
|
|
1759
|
|
|
18
|
|
|
|
|
124
|
|
|
18
|
|
|
|
|
43
|
|
|
18
|
|
|
|
|
5705
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
$self->verbose($cmd); |
78
|
|
|
|
|
|
|
|
79
|
0
|
0
|
|
|
|
|
if ($capture) { |
80
|
|
|
|
|
|
|
my ( $stdout, $stderr, $exit ) = capture { |
81
|
0
|
|
|
0
|
|
|
system($cmd); |
82
|
0
|
|
|
|
|
|
}; |
83
|
|
|
|
|
|
|
|
84
|
0
|
0
|
0
|
|
|
|
if ( $exit and $confess_on_err ) { |
85
|
0
|
|
|
|
|
|
confess $stderr; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
return ( $stdout, $stderr, $exit ); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
else { |
91
|
0
|
|
|
|
|
|
system($cmd); |
92
|
0
|
|
|
|
|
|
my $exit = $? >> 8; |
93
|
|
|
|
|
|
|
|
94
|
0
|
0
|
0
|
|
|
|
if ( $exit and $confess_on_err ) { |
95
|
0
|
|
|
|
|
|
confess "last command failed with exit code $exit"; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
return $exit; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
18
|
0
|
0
|
18
|
|
71492
|
method verbose (Str $str, Num $frames? = 1) { |
|
18
|
0
|
|
18
|
|
45
|
|
|
18
|
0
|
|
18
|
|
3752
|
|
|
18
|
0
|
|
0
|
|
156
|
|
|
18
|
0
|
|
|
|
42
|
|
|
18
|
0
|
|
|
|
2283
|
|
|
18
|
0
|
|
|
|
138
|
|
|
18
|
0
|
|
|
|
46
|
|
|
18
|
|
|
|
|
2145
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
$self->_verbose( 1, $str, $frames + 1 ); |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
18
|
0
|
0
|
18
|
|
69315
|
method verbose2 (Str $str, Num $frames? = 1) { |
|
18
|
0
|
|
18
|
|
49
|
|
|
18
|
0
|
|
18
|
|
3622
|
|
|
18
|
0
|
|
0
|
|
175
|
|
|
18
|
0
|
|
|
|
671
|
|
|
18
|
0
|
|
|
|
2420
|
|
|
18
|
0
|
|
|
|
201
|
|
|
18
|
0
|
|
|
|
45
|
|
|
18
|
|
|
|
|
2037
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
$self->_verbose( 2, $str, $frames + 1 ); |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
18
|
0
|
0
|
18
|
|
68229
|
method verbose3 (Str $str, Num $frames? = 1) { |
|
18
|
0
|
|
18
|
|
532
|
|
|
18
|
0
|
|
18
|
|
3799
|
|
|
18
|
0
|
|
0
|
|
158
|
|
|
18
|
0
|
|
|
|
70
|
|
|
18
|
0
|
|
|
|
2398
|
|
|
18
|
0
|
|
|
|
138
|
|
|
18
|
0
|
|
|
|
40
|
|
|
18
|
|
|
|
|
1909
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
114
|
0
|
|
|
|
|
|
$self->_verbose( 3, $str, $frames + 1 ); |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
18
|
0
|
0
|
18
|
|
67924
|
method warn (Str $str, Num $frames? = 1) { |
|
18
|
0
|
|
18
|
|
49
|
|
|
18
|
0
|
|
18
|
|
3897
|
|
|
18
|
0
|
|
0
|
|
140
|
|
|
18
|
0
|
|
|
|
38
|
|
|
18
|
0
|
|
|
|
2413
|
|
|
18
|
0
|
|
|
|
138
|
|
|
18
|
0
|
|
|
|
39
|
|
|
18
|
|
|
|
|
3429
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
|
chomp $str; |
120
|
|
|
|
|
|
|
|
121
|
0
|
|
|
|
|
|
my $caller = ''; |
122
|
0
|
0
|
|
|
|
|
if ($frames) { |
123
|
0
|
|
|
|
|
|
$caller = sprintf " %s", ( caller($frames) )[3]; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
0
|
|
|
|
|
|
printf STDERR "[WARN%s] $str\n", $caller; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
###################################################################### |
130
|
|
|
|
|
|
|
|
131
|
18
|
0
|
|
18
|
|
23323
|
method _build_verbosity { |
|
18
|
|
|
0
|
|
50
|
|
|
18
|
|
|
|
|
2299
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
|
133
|
0
|
|
|
|
|
|
my $level = 0; |
134
|
0
|
0
|
|
|
|
|
$level = $ENV{VERBOSE} if $ENV{VERBOSE}; |
135
|
|
|
|
|
|
|
|
136
|
0
|
|
|
|
|
|
return $level; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
18
|
0
|
0
|
18
|
|
78163
|
method _verbose (Num $level, Str $str, Num $frames) { |
|
18
|
0
|
0
|
18
|
|
53
|
|
|
18
|
0
|
|
18
|
|
3577
|
|
|
18
|
0
|
|
18
|
|
187
|
|
|
18
|
0
|
|
0
|
|
57
|
|
|
18
|
0
|
|
|
|
3042
|
|
|
18
|
0
|
|
|
|
179
|
|
|
18
|
0
|
|
|
|
41
|
|
|
18
|
0
|
|
|
|
2148
|
|
|
18
|
0
|
|
|
|
129
|
|
|
18
|
0
|
|
|
|
58
|
|
|
18
|
|
|
|
|
4464
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
|
141
|
0
|
0
|
|
|
|
|
if ( $self->verbosity >= $level ) { |
142
|
0
|
|
|
|
|
|
chomp $str; |
143
|
0
|
|
|
|
|
|
my $caller = ( caller($frames) )[3]; |
144
|
0
|
|
|
|
|
|
printf STDERR "[VERBOSE-%d] ($caller) $str\n", $level; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
1; |