line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use Catmandu::Sane; |
3
|
14
|
|
|
14
|
|
122339
|
|
|
14
|
|
|
|
|
29
|
|
|
14
|
|
|
|
|
109
|
|
4
|
|
|
|
|
|
|
our $VERSION = '1.2018'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use Catmandu::Util qw(is_instance); |
7
|
14
|
|
|
14
|
|
89
|
use Catmandu; |
|
14
|
|
|
|
|
26
|
|
|
14
|
|
|
|
|
635
|
|
8
|
14
|
|
|
14
|
|
525
|
use Log::Any::Adapter; |
|
14
|
|
|
|
|
25
|
|
|
14
|
|
|
|
|
70
|
|
9
|
14
|
|
|
14
|
|
8070
|
use Data::Dumper; |
|
14
|
|
|
|
|
4658
|
|
|
14
|
|
|
|
|
47
|
|
10
|
14
|
|
|
14
|
|
367
|
|
|
14
|
|
|
|
|
23
|
|
|
14
|
|
|
|
|
646
|
|
11
|
|
|
|
|
|
|
use parent qw(App::Cmd); |
12
|
14
|
|
|
14
|
|
77
|
|
|
14
|
|
|
|
|
78
|
|
|
14
|
|
|
|
|
69
|
|
13
|
|
|
|
|
|
|
[ |
14
|
|
|
|
|
|
|
qw( |
15
|
|
|
|
|
|
|
Catmandu::Cmd::data |
16
|
624
|
|
|
624
|
0
|
1672
|
Catmandu::Cmd::exporter_info |
17
|
|
|
|
|
|
|
Catmandu::Cmd::fix_info |
18
|
|
|
|
|
|
|
Catmandu::Cmd::importer_info |
19
|
|
|
|
|
|
|
Catmandu::Cmd::module_info |
20
|
|
|
|
|
|
|
Catmandu::Cmd::move |
21
|
|
|
|
|
|
|
Catmandu::Cmd::store_info |
22
|
|
|
|
|
|
|
) |
23
|
|
|
|
|
|
|
]; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
1
|
1
|
955
|
(['debug|D:i', ""], ['load_path|L=s@', ""], ['lib_path|I=s@', ""]); |
29
|
|
|
|
|
|
|
} |
30
|
14
|
|
|
14
|
1
|
12527
|
|
31
|
|
|
|
|
|
|
my $level = shift // 'DEBUG'; |
32
|
|
|
|
|
|
|
my $appender = shift // 'STDERR'; |
33
|
141
|
|
|
141
|
1
|
9197
|
|
34
|
|
|
|
|
|
|
my $config = <<EOF; |
35
|
|
|
|
|
|
|
log4perl.category.Catmandu=$level,$appender |
36
|
|
|
|
|
|
|
log4perl.category.Catmandu::Fix::log=TRACE,$appender |
37
|
2
|
|
50
|
2
|
0
|
10
|
|
38
|
2
|
|
50
|
|
|
9
|
log4perl.appender.STDOUT=Log::Log4perl::Appender::Screen |
39
|
|
|
|
|
|
|
log4perl.appender.STDOUT.stderr=0 |
40
|
2
|
|
|
|
|
12
|
log4perl.appender.STDOUT.utf8=1 |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
log4perl.appender.STDOUT.layout=PatternLayout |
43
|
|
|
|
|
|
|
log4perl.appender.STDOUT.layout.ConversionPattern=%d [%P] - %p %l %M time=%r : %m%n |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
log4perl.appender.STDERR=Log::Log4perl::Appender::Screen |
46
|
|
|
|
|
|
|
log4perl.appender.STDERR.stderr=1 |
47
|
|
|
|
|
|
|
log4perl.appender.STDERR.utf8=1 |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
log4perl.appender.STDERR.layout=PatternLayout |
50
|
|
|
|
|
|
|
log4perl.appender.STDERR.layout.ConversionPattern=%d [%P] - %l : %m%n |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
EOF |
53
|
|
|
|
|
|
|
\$config; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
my %LEVELS = (1 => 'WARN', 2 => 'INFO', 3 => 'DEBUG'); |
57
|
|
|
|
|
|
|
my $debug = shift; |
58
|
|
|
|
|
|
|
my $level = $LEVELS{$debug} // 'WARN'; |
59
|
2
|
|
|
|
|
14
|
my $load_from; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
try { |
62
|
|
|
|
|
|
|
my $log4perl_pkg = Catmandu::Util::require_package('Log::Log4perl'); |
63
|
4
|
|
|
4
|
0
|
33
|
my $logany_adapter |
64
|
4
|
|
|
|
|
17
|
= Catmandu::Util::require_package('Log::Any::Adapter::Log4perl'); |
65
|
4
|
|
100
|
|
|
29
|
my $config = Catmandu->config->{log4perl}; |
66
|
4
|
|
|
|
|
8
|
|
67
|
|
|
|
|
|
|
if (defined $config) { |
68
|
|
|
|
|
|
|
if ($config =~ /^\S+$/) { |
69
|
4
|
|
|
4
|
|
460
|
Log::Log4perl::init($config); |
70
|
4
|
|
|
|
|
15
|
$load_from = "file: $config"; |
71
|
|
|
|
|
|
|
} |
72
|
4
|
|
|
|
|
42
|
else { |
73
|
|
|
|
|
|
|
Log::Log4perl::init(\$config); |
74
|
4
|
100
|
|
|
|
21
|
$load_from = "string: <defined in catmandu.yml>"; |
75
|
2
|
100
|
|
|
|
18
|
} |
76
|
1
|
|
|
|
|
8
|
} |
77
|
1
|
|
|
|
|
7144
|
else { |
78
|
|
|
|
|
|
|
Log::Log4perl::init(default_log4perl_config($level, 'STDERR')); |
79
|
|
|
|
|
|
|
$load_from = "string: <defined in " . __PACKAGE__ . ">"; |
80
|
1
|
|
|
|
|
8
|
} |
81
|
1
|
|
|
|
|
6186
|
|
82
|
|
|
|
|
|
|
Log::Any::Adapter->set('Log4perl'); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
catch { |
85
|
2
|
|
|
|
|
14
|
print STDERR <<EOF; |
86
|
2
|
|
|
|
|
14247
|
|
87
|
|
|
|
|
|
|
Oops! Debugging tools not available on this platform |
88
|
|
|
|
|
|
|
|
89
|
4
|
|
|
|
|
69
|
Try to install Log::Log4perl and Log::Any::Adapter::Log4perl |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Hint: cpan Log::Log4perl Log::Any::Adapter::Log4perl |
92
|
0
|
|
|
0
|
|
0
|
EOF |
93
|
|
|
|
|
|
|
exit(2); |
94
|
|
|
|
|
|
|
}; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Catmandu->log->warn( |
97
|
|
|
|
|
|
|
"debug activated - level $level - config load from $load_from"); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
0
|
# overload run to read the global options before |
101
|
4
|
|
|
|
|
148
|
# the App::Cmd object is created |
102
|
|
|
|
|
|
|
my ($class) = @_; |
103
|
4
|
|
|
|
|
2951
|
|
104
|
|
|
|
|
|
|
my ($global_opts, $argv) |
105
|
|
|
|
|
|
|
= $class->_process_args([@ARGV], |
106
|
|
|
|
|
|
|
$class->_global_option_processing_params); |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
my $load_path = $global_opts->{load_path} || []; |
109
|
|
|
|
|
|
|
my $lib_path = $global_opts->{lib_path} || []; |
110
|
48
|
|
|
48
|
1
|
71077
|
|
111
|
|
|
|
|
|
|
if (exists $global_opts->{debug}) { |
112
|
48
|
|
|
|
|
361
|
setup_debugging($global_opts->{debug} // 1); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
if (@$lib_path) { |
116
|
48
|
|
50
|
|
|
339830
|
Catmandu::Util::use_lib(@$lib_path); |
117
|
48
|
|
100
|
|
|
263
|
} |
118
|
|
|
|
|
|
|
|
119
|
48
|
100
|
|
|
|
208
|
Catmandu->load(@$load_path); |
120
|
4
|
|
50
|
|
|
34
|
|
121
|
|
|
|
|
|
|
my $self = ref $class ? $class : $class->new; |
122
|
|
|
|
|
|
|
$self->set_global_options($global_opts); |
123
|
48
|
100
|
|
|
|
3194
|
my ($cmd, $opts, @args) = $self->prepare_command(@$argv); |
124
|
2
|
|
|
|
|
12
|
|
125
|
|
|
|
|
|
|
my $err; |
126
|
|
|
|
|
|
|
|
127
|
48
|
|
|
|
|
392
|
try { |
128
|
|
|
|
|
|
|
$self->execute_command($cmd, $opts, @args); |
129
|
48
|
50
|
|
|
|
197
|
} |
130
|
48
|
|
|
|
|
386
|
catch { |
131
|
48
|
|
|
|
|
476
|
my $e = $_; |
132
|
|
|
|
|
|
|
if (is_instance($e, 'Catmandu::NoSuchPackage') |
133
|
48
|
|
|
|
|
103931
|
&& $e->package_name eq 'Catmandu::Importer::help') |
134
|
|
|
|
|
|
|
{ |
135
|
|
|
|
|
|
|
$err = "Did you mean 'catmandu $ARGV[1] $ARGV[0]'?"; |
136
|
48
|
|
|
48
|
|
4467
|
} |
137
|
|
|
|
|
|
|
elsif (is_instance($e, 'Catmandu::Error')) { |
138
|
|
|
|
|
|
|
$err = $e->log_message; |
139
|
8
|
|
|
8
|
|
2164
|
} |
140
|
8
|
100
|
100
|
|
|
48
|
else { |
|
|
50
|
|
|
|
|
|
141
|
|
|
|
|
|
|
$err = $e; |
142
|
|
|
|
|
|
|
} |
143
|
1
|
|
|
|
|
65
|
}; |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
if (defined $err) { |
146
|
7
|
|
|
|
|
63
|
say STDERR "Oops! $err"; |
147
|
|
|
|
|
|
|
return; |
148
|
|
|
|
|
|
|
} |
149
|
0
|
|
|
|
|
0
|
|
150
|
|
|
|
|
|
|
1; |
151
|
48
|
|
|
|
|
520
|
} |
152
|
|
|
|
|
|
|
|
153
|
48
|
100
|
|
|
|
74829
|
my ($self, $cmd_class) = @_; |
154
|
8
|
|
|
|
|
70
|
for my $cmd (@{$self->deleted_commands}) { |
155
|
8
|
|
|
|
|
652
|
return 1 if $cmd_class->isa($cmd); |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
return; |
158
|
40
|
|
|
|
|
1256
|
} |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
1; |
161
|
|
|
|
|
|
|
|
162
|
624
|
|
|
624
|
0
|
77182
|
|
163
|
624
|
|
|
|
|
804
|
=pod |
|
624
|
|
|
|
|
1100
|
|
164
|
4368
|
50
|
|
|
|
14104
|
|
165
|
|
|
|
|
|
|
=head1 NAME |
166
|
624
|
|
|
|
|
1296
|
|
167
|
|
|
|
|
|
|
Catmandu::CLI - The App::Cmd application class for the catmandu command line script |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 SEE ALSO |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
L<catmandu> |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=cut |