| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# ============================================================================ |
|
2
|
|
|
|
|
|
|
package Mac::iPhoto::Exif::Commandline; |
|
3
|
|
|
|
|
|
|
# ============================================================================ |
|
4
|
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
4326
|
use 5.010; |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
52
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use utf8; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
8
|
|
|
7
|
1
|
|
|
1
|
|
41
|
no if $] >= 5.017004, warnings => qw(experimental::smartmatch); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
36
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
71
|
use Moose; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
167
|
|
|
10
|
|
|
|
|
|
|
with qw(MooseX::Getopt); |
|
11
|
|
|
|
|
|
|
extends qw(Mac::iPhoto::Exif); |
|
12
|
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
20254
|
use Moose::Util::TypeConstraints; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
19
|
|
|
14
|
1
|
|
|
1
|
|
5899
|
use Term::ANSIColor; |
|
|
1
|
|
|
|
|
15964
|
|
|
|
1
|
|
|
|
|
680
|
|
|
15
|
1
|
|
|
1
|
|
30
|
use Scalar::Util qw(weaken); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
1808
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has 'force' => ( |
|
18
|
|
|
|
|
|
|
is => 'ro', |
|
19
|
|
|
|
|
|
|
isa => 'Bool', |
|
20
|
|
|
|
|
|
|
default => 0, |
|
21
|
|
|
|
|
|
|
documentation => 'Do not confirm action [Default: false]', |
|
22
|
|
|
|
|
|
|
); |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has 'loglevel' => ( |
|
25
|
|
|
|
|
|
|
is => 'ro', |
|
26
|
|
|
|
|
|
|
isa => enum(\@Mac::iPhoto::Exif::LEVELS), |
|
27
|
|
|
|
|
|
|
default => 'info', |
|
28
|
|
|
|
|
|
|
documentation => 'Log level [Values: '.join(',',@Mac::iPhoto::Exif::LEVELS).'; Default: info]', |
|
29
|
|
|
|
|
|
|
); |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
MooseX::Getopt::OptionTypeMap->add_option_type_to_map( |
|
32
|
|
|
|
|
|
|
'Mac::iPhoto::Exif::Type::File' => '=s', |
|
33
|
|
|
|
|
|
|
); |
|
34
|
|
|
|
|
|
|
MooseX::Getopt::OptionTypeMap->add_option_type_to_map( |
|
35
|
|
|
|
|
|
|
'Mac::iPhoto::Exif::Type::Dirs' => '=s@', |
|
36
|
|
|
|
|
|
|
); |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
after 'log' => sub { |
|
40
|
|
|
|
|
|
|
my ($self,$loglevel,$message,@params) = @_; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my $logmessage = sprintf( $message, map { $_ // '000000' } @params ); |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
my ($level_pos) = grep { $Mac::iPhoto::Exif::LEVELS[$_] eq $loglevel } 0 .. $#Mac::iPhoto::Exif::LEVELS; |
|
45
|
|
|
|
|
|
|
my ($level_max) = grep { $Mac::iPhoto::Exif::LEVELS[$_] eq $self->loglevel } 0 .. $#Mac::iPhoto::Exif::LEVELS; |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
if ($level_pos >= $level_max) { |
|
48
|
|
|
|
|
|
|
given ($loglevel) { |
|
49
|
|
|
|
|
|
|
when ('error') { |
|
50
|
|
|
|
|
|
|
print color 'bold red'; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
when ('warn') { |
|
53
|
|
|
|
|
|
|
print color 'bold bright_yellow'; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
when ('info') { |
|
56
|
|
|
|
|
|
|
print color 'bold cyan'; |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
when ('debug') { |
|
59
|
|
|
|
|
|
|
print color 'bold white'; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
printf "%5s: ",$loglevel; |
|
63
|
|
|
|
|
|
|
print color 'reset'; |
|
64
|
|
|
|
|
|
|
say $logmessage; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
}; |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
around 'run' => sub { |
|
69
|
|
|
|
|
|
|
my $orig = shift; |
|
70
|
|
|
|
|
|
|
my $self = shift; |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
my $self_copy = $self; |
|
73
|
|
|
|
|
|
|
weaken($self_copy); |
|
74
|
|
|
|
|
|
|
local $SIG{__WARN__} = sub { |
|
75
|
|
|
|
|
|
|
my ($message) = shift; |
|
76
|
|
|
|
|
|
|
chomp $message; |
|
77
|
|
|
|
|
|
|
$self_copy->log('warn',$message); |
|
78
|
|
|
|
|
|
|
}; |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
binmode STDOUT, ":utf8"; |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
unless ($self->backup || $self->force || $self->dryrun) { |
|
83
|
|
|
|
|
|
|
$self->log('warn','Your pictures will be altered without backup. Type "yes" if you want to continue!'); |
|
84
|
|
|
|
|
|
|
my $confirm = <STDIN>; |
|
85
|
|
|
|
|
|
|
chomp($confirm); |
|
86
|
|
|
|
|
|
|
exit() |
|
87
|
|
|
|
|
|
|
unless $confirm =~ m/^\s*yes\s*$/i; |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
$self->$orig(@_); |
|
91
|
|
|
|
|
|
|
}; |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
94
|
1
|
|
|
1
|
|
9
|
no Moose; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
12
|
|
|
95
|
|
|
|
|
|
|
1; |
|
96
|
|
|
|
|
|
|
|