line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Critique::Plugin::UI; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
14641
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
91
|
|
4
|
3
|
|
|
3
|
|
18
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
148
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
7
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:STEVAN'; |
8
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
20
|
use Term::ReadKey (); |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
46
|
|
10
|
3
|
|
|
3
|
|
1571
|
use Number::Format (); |
|
3
|
|
|
|
|
25635
|
|
|
3
|
|
|
|
|
315
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub TERM_WIDTH () { |
13
|
9
|
|
50
|
9
|
0
|
26
|
my $size = eval { |
14
|
9
|
|
|
9
|
|
62576
|
local $SIG{__WARN__} = sub {''}; |
15
|
|
|
|
|
|
|
( Term::ReadKey::GetTerminalSize() )[0]; |
16
|
|
|
|
|
|
|
} || 80; |
17
|
|
|
|
|
|
|
|
18
|
9
|
|
|
|
|
1777
|
return $size; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
3
|
|
|
3
|
|
29
|
use constant HR_ERROR => ( '== ERROR ' . ( '=' x ( TERM_WIDTH - 9 ) ) ); |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
11
|
|
22
|
3
|
|
|
3
|
|
110
|
use constant HR_DARK => ( '=' x TERM_WIDTH ); |
|
3
|
|
|
|
|
16
|
|
|
3
|
|
|
|
|
15
|
|
23
|
3
|
|
|
3
|
|
42
|
use constant HR_LIGHT => ( '-' x TERM_WIDTH ); |
|
3
|
|
|
|
|
13
|
|
|
3
|
|
|
|
|
18
|
|
24
|
|
|
|
|
|
|
|
25
|
3
|
|
|
3
|
|
46
|
use App::Critique -ignore; |
|
3
|
|
|
|
|
16
|
|
|
3
|
|
|
|
|
96
|
|
26
|
|
|
|
|
|
|
|
27
|
3
|
|
|
|
|
78
|
use App::Cmd::Setup -plugin => { |
28
|
|
|
|
|
|
|
exports => [qw[ |
29
|
|
|
|
|
|
|
TERM_WIDTH |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
HR_ERROR |
32
|
|
|
|
|
|
|
HR_DARK |
33
|
|
|
|
|
|
|
HR_LIGHT |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
info |
36
|
|
|
|
|
|
|
warning |
37
|
|
|
|
|
|
|
error |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
format_number |
40
|
|
|
|
|
|
|
format_bytes |
41
|
|
|
|
|
|
|
]] |
42
|
3
|
|
|
3
|
|
1066
|
}; |
|
3
|
|
|
|
|
9
|
|
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
0
|
0
|
|
sub info { my ($plugin, $cmd, @args) = @_; _info( @args ) } |
|
0
|
|
|
|
|
|
|
45
|
0
|
|
|
0
|
0
|
|
sub warning { my ($plugin, $cmd, @args) = @_; _warning( @args ) } |
|
0
|
|
|
|
|
|
|
46
|
0
|
|
|
0
|
0
|
|
sub error { my ($plugin, $cmd, @args) = @_; _error( @args ) } |
|
0
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub format_number { |
49
|
0
|
|
|
0
|
0
|
|
my ($plugin, $cmd, @args) = @_; |
50
|
0
|
|
|
|
|
|
Number::Format::format_number( @args ); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub format_bytes { |
54
|
0
|
|
|
0
|
0
|
|
my ($plugin, $cmd, @args) = @_; |
55
|
0
|
|
|
|
|
|
Number::Format::format_bytes( @args ); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# the real stuff |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub _info { |
61
|
0
|
|
|
0
|
|
|
my ($msg, @args) = @_; |
62
|
0
|
|
|
|
|
|
print((sprintf $msg, @args), "\n"); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub _warning { |
66
|
0
|
|
|
0
|
|
|
my ($msg, @args) = @_; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# NOTE: |
69
|
|
|
|
|
|
|
# I had a timestamp here, but it didn't |
70
|
|
|
|
|
|
|
# really help any with the readability, |
71
|
|
|
|
|
|
|
# so I took it out, just in case I want |
72
|
|
|
|
|
|
|
# it back. I am leaving it here so I |
73
|
|
|
|
|
|
|
# don't need to work this out again. |
74
|
|
|
|
|
|
|
# - SL |
75
|
|
|
|
|
|
|
# my @time = (localtime)[ 2, 1, 0, 4, 3, 5 ]; |
76
|
|
|
|
|
|
|
# $time[-1] += 1900; |
77
|
|
|
|
|
|
|
# sprintf '%02d:%02d:%02d-%02d/%02d/%d', @time; |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
warn((sprintf $msg, @args),"\n"); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub _error { |
83
|
0
|
|
|
0
|
|
|
my ($msg, @args) = @_; |
84
|
0
|
|
|
|
|
|
die(HR_ERROR,"\n",(sprintf $msg, @args),"\n",HR_DARK,"\n"); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=pod |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 NAME |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
App::Critique::Plugin::UI - UI elements for App::Critique |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 VERSION |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
version 0.05 |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 DESCRIPTION |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Just a simple L<App::Cmd::Plugin> to handle UI elements, nothing |
102
|
|
|
|
|
|
|
really useful in here. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 AUTHOR |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Stevan Little <stevan@cpan.org> |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
This software is copyright (c) 2016 by Stevan Little. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
113
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=cut |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
__END__ |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# ABSTRACT: UI elements for App::Critique |
120
|
|
|
|
|
|
|
|