| 1 | #!/usr/bin/env perl | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | use lib 'lib'; | ||
| 5 | use lib 't/lib'; | ||
| 6 | use Term::ANSIColor qw(colored); | ||
| 7 | use UNIVERSAL::require; | ||
| 8 | use UNIVERSAL::source_location_for; | ||
| 9 | use Pod::Usage; | ||
| 10 | my ($class, $method) = @ARGV; | ||
| 11 | unless ($class && $method) { | ||
| 12 | pod2usage; | ||
| 13 | } | ||
| 14 | |||
| 15 | $class->require or die $@; | ||
| 16 | my ($file, $line) = do { | ||
| 17 | local $SIG{__WARN__} = sub {}; | ||
| 18 | $class->source_location_for($method) | ||
| 19 | }; | ||
| 20 | |||
| 21 | unless (defined($file) && defined($line)) { | ||
| 22 | print colored(qq|method "${class}::$method" is not found.|, 'red'), "\n"; | ||
| 23 | exit 1; | ||
| 24 | } | ||
| 25 | |||
| 26 | print colored('FILENAME ', 'green') . "$file\n"; | ||
| 27 | print colored('LINE ', 'green') . "$line\n"; | ||
| 28 | |||
| 29 | =encoding utf-8 | ||
| 30 | |||
| 31 | =head1 SYNOPSIS | ||
| 32 | |||
| 33 | $ source_location.pl <Module> <method> | ||
| 34 | |||
| 35 | =cut |