line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::GitGrepPerlStatement; |
2
|
1
|
|
|
1
|
|
809
|
use 5.008001; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
112
|
|
3
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
37
|
|
4
|
1
|
|
|
1
|
|
13
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
5
|
1
|
|
|
1
|
|
395
|
use App::GitGrepPerlStatement::StatementFinder; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
6
|
1
|
|
|
1
|
|
11
|
use Term::ANSIColor qw(colored); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
318
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = "0.05"; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub say ($) { |
11
|
0
|
|
|
0
|
0
|
|
my ($message) = @_; |
12
|
0
|
|
|
|
|
|
print $message . "\n"; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub run { |
16
|
0
|
|
|
0
|
0
|
|
my ($class, @argv) = @_; |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
my $word = (@argv)[0]; |
19
|
|
|
|
|
|
|
|
20
|
0
|
0
|
|
|
|
|
unless (defined $word) { |
21
|
0
|
|
|
|
|
|
say "USAGE: git grep-per-statement "; |
22
|
0
|
|
|
|
|
|
exit 1; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
my @files = split "\n", `git grep --name-only --cached --word-regexp @{[ join ' ', map { quotemeta($_) } @argv ]}`; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
my $finder = App::GitGrepPerlStatement::StatementFinder->new($word); |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
for my $file (@files) { |
30
|
0
|
|
|
|
|
|
my @found = $finder->search($file); |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
for (@found) { |
33
|
0
|
0
|
|
|
|
|
if (-t STDOUT) { |
34
|
0
|
|
|
|
|
|
say colored( |
35
|
|
|
|
|
|
|
['bold'], |
36
|
0
|
|
|
|
|
|
"@{[ $file ]}:@{[ $_->line_number ]}" |
|
0
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
); |
38
|
0
|
|
|
|
|
|
say $finder->highlight($_); |
39
|
|
|
|
|
|
|
} else { |
40
|
0
|
|
|
|
|
|
say "@{[ $file ]}:@{[ $_->line_number ]}"; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
say $_; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
0
|
|
|
|
|
|
$finder->flush; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
__END__ |