| 1 | package App::GitGrepPerlStatement; | ||||||||||
| 2 | 1 | ▶ | use 5.008001; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use App::GitGrepPerlStatement::StatementFinder; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use Term::ANSIColor qw(colored); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 1 | our $VERSION = "0.05"; | |||||||||
| 9 | |||||||||||
| 10 | 0 | ▶ | sub say ($) { | ||||||||
|
Subroutine
say: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 11 | 0 | my ($message) = @_; | |||||||||
| 12 | 0 | print $message . "\n"; | |||||||||
| 13 | } | ||||||||||
| 14 | |||||||||||
| 15 | 0 | ▶ | sub run { | ||||||||
|
Subroutine
run: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||
| 16 | 0 | my ($class, @argv) = @_; | |||||||||
| 17 | |||||||||||
| 18 | 0 | my $word = (@argv)[0]; | |||||||||
| 19 | |||||||||||
| 20 | 0 | ▶ | unless (defined $word) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 21 | 0 | say "USAGE: git grep-per-statement <pattern token> <pathspec>"; | |||||||||
| 22 | 0 | exit 1; | |||||||||
| 23 | } | ||||||||||
| 24 | |||||||||||
| 25 | 0 | my @files = split "\n", `git grep --name-only --cached --word-regexp @{[ join ' ', map { quotemeta($_) } @argv ]}`; | |||||||||
| 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 | ▶ | if (-t STDOUT) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | 0 | say colored( | |||||||||
| 35 | ['bold'], | ||||||||||
| 36 | 0 | "@{[ $file ]}:@{[ $_->line_number ]}" | |||||||||
| 37 | ); | ||||||||||
| 38 | 0 | say $finder->highlight($_); | |||||||||
| 39 | } else { | ||||||||||
| 40 | 0 | say "@{[ $file ]}:@{[ $_->line_number ]}"; | |||||||||
| 41 | 0 | say $_; | |||||||||
| 42 | } | ||||||||||
| 43 | } | ||||||||||
| 44 | 0 | $finder->flush; | |||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | } | ||||||||||
| 48 | |||||||||||
| 49 | __END__ | ||||||||||