line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use Catmandu::Sane; |
3
|
14
|
|
|
14
|
|
123514
|
|
|
14
|
|
|
|
|
28
|
|
|
14
|
|
|
|
|
99
|
|
4
|
|
|
|
|
|
|
our $VERSION = '1.2019'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use Catmandu::Util qw(is_instance); |
7
|
14
|
|
|
14
|
|
92
|
use Catmandu; |
|
14
|
|
|
|
|
25
|
|
|
14
|
|
|
|
|
634
|
|
8
|
14
|
|
|
14
|
|
455
|
use Log::Any::Adapter; |
|
14
|
|
|
|
|
27
|
|
|
14
|
|
|
|
|
115
|
|
9
|
14
|
|
|
14
|
|
8313
|
use Data::Dumper; |
|
14
|
|
|
|
|
4875
|
|
|
14
|
|
|
|
|
58
|
|
10
|
14
|
|
|
14
|
|
377
|
|
|
14
|
|
|
|
|
28
|
|
|
14
|
|
|
|
|
752
|
|
11
|
|
|
|
|
|
|
use parent qw(App::Cmd); |
12
|
14
|
|
|
14
|
|
77
|
|
|
14
|
|
|
|
|
60
|
|
|
14
|
|
|
|
|
85
|
|
13
|
|
|
|
|
|
|
[ |
14
|
|
|
|
|
|
|
qw( |
15
|
|
|
|
|
|
|
Catmandu::Cmd::data |
16
|
624
|
|
|
624
|
0
|
1759
|
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
|
943
|
(['debug|D:i', ""], ['load_path|L=s@', ""], ['lib_path|I=s@', ""]); |
29
|
|
|
|
|
|
|
} |
30
|
14
|
|
|
14
|
1
|
14013
|
|
31
|
|
|
|
|
|
|
my $level = shift // 'DEBUG'; |
32
|
|
|
|
|
|
|
my $appender = shift // 'STDERR'; |
33
|
141
|
|
|
141
|
1
|
8568
|
|
34
|
|
|
|
|
|
|
my $config = <<EOF; |
35
|
|
|
|
|
|
|
log4perl.category.Catmandu=$level,$appender |
36
|
|
|
|
|
|
|
log4perl.category.Catmandu::Fix::log=TRACE,$appender |
37
|
2
|
|
50
|
2
|
0
|
7
|
|
38
|
2
|
|
50
|
|
|
6
|
log4perl.appender.STDOUT=Log::Log4perl::Appender::Screen |
39
|
|
|
|
|
|
|
log4perl.appender.STDOUT.stderr=0 |
40
|
2
|
|
|
|
|
10
|
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
|
|
|
|
|
9
|
my $load_from; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
try { |
62
|
|
|
|
|
|
|
my $log4perl_pkg = Catmandu::Util::require_package('Log::Log4perl'); |
63
|
4
|
|
|
4
|
0
|
21
|
my $logany_adapter |
64
|
4
|
|
|
|
|
9
|
= Catmandu::Util::require_package('Log::Any::Adapter::Log4perl'); |
65
|
4
|
|
100
|
|
|
18
|
my $config = Catmandu->config->{log4perl}; |
66
|
4
|
|
|
|
|
5
|
|
67
|
|
|
|
|
|
|
if (defined $config) { |
68
|
|
|
|
|
|
|
if ($config =~ /^\S+$/) { |
69
|
4
|
|
|
4
|
|
268
|
Log::Log4perl::init($config); |
70
|
4
|
|
|
|
|
10
|
$load_from = "file: $config"; |
71
|
|
|
|
|
|
|
} |
72
|
4
|
|
|
|
|
24
|
else { |
73
|
|
|
|
|
|
|
Log::Log4perl::init(\$config); |
74
|
4
|
100
|
|
|
|
13
|
$load_from = "string: <defined in catmandu.yml>"; |
75
|
2
|
100
|
|
|
|
14
|
} |
76
|
1
|
|
|
|
|
6
|
} |
77
|
1
|
|
|
|
|
5946
|
else { |
78
|
|
|
|
|
|
|
Log::Log4perl::init(default_log4perl_config($level, 'STDERR')); |
79
|
|
|
|
|
|
|
$load_from = "string: <defined in " . __PACKAGE__ . ">"; |
80
|
1
|
|
|
|
|
5
|
} |
81
|
1
|
|
|
|
|
5829
|
|
82
|
|
|
|
|
|
|
Log::Any::Adapter->set('Log4perl'); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
catch { |
85
|
2
|
|
|
|
|
9
|
print STDERR <<EOF; |
86
|
2
|
|
|
|
|
12321
|
|
87
|
|
|
|
|
|
|
Oops! Debugging tools not available on this platform |
88
|
|
|
|
|
|
|
|
89
|
4
|
|
|
|
|
32
|
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
|
|
|
|
|
83
|
# the App::Cmd object is created |
102
|
|
|
|
|
|
|
my ($class) = @_; |
103
|
4
|
|
|
|
|
2404
|
|
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
|
71856
|
|
111
|
|
|
|
|
|
|
if (exists $global_opts->{debug}) { |
112
|
48
|
|
|
|
|
337
|
setup_debugging($global_opts->{debug} // 1); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
if (@$lib_path) { |
116
|
48
|
|
50
|
|
|
358105
|
Catmandu::Util::use_lib(@$lib_path); |
117
|
48
|
|
100
|
|
|
241
|
} |
118
|
|
|
|
|
|
|
|
119
|
48
|
100
|
|
|
|
189
|
Catmandu->load(@$load_path); |
120
|
4
|
|
50
|
|
|
16
|
|
121
|
|
|
|
|
|
|
my $self = ref $class ? $class : $class->new; |
122
|
|
|
|
|
|
|
$self->set_global_options($global_opts); |
123
|
48
|
100
|
|
|
|
2127
|
my ($cmd, $opts, @args) = $self->prepare_command(@$argv); |
124
|
2
|
|
|
|
|
11
|
|
125
|
|
|
|
|
|
|
my $err; |
126
|
|
|
|
|
|
|
|
127
|
48
|
|
|
|
|
371
|
try { |
128
|
|
|
|
|
|
|
$self->execute_command($cmd, $opts, @args); |
129
|
48
|
50
|
|
|
|
183
|
} |
130
|
48
|
|
|
|
|
344
|
catch { |
131
|
48
|
|
|
|
|
399
|
my $e = $_; |
132
|
|
|
|
|
|
|
if (is_instance($e, 'Catmandu::NoSuchPackage') |
133
|
48
|
|
|
|
|
102004
|
&& $e->package_name eq 'Catmandu::Importer::help') |
134
|
|
|
|
|
|
|
{ |
135
|
|
|
|
|
|
|
$err = "Did you mean 'catmandu $ARGV[1] $ARGV[0]'?"; |
136
|
48
|
|
|
48
|
|
4124
|
} |
137
|
|
|
|
|
|
|
elsif (is_instance($e, 'Catmandu::Error')) { |
138
|
|
|
|
|
|
|
$err = $e->log_message; |
139
|
8
|
|
|
8
|
|
1353
|
} |
140
|
8
|
100
|
100
|
|
|
30
|
else { |
|
|
50
|
|
|
|
|
|
141
|
|
|
|
|
|
|
$err = $e; |
142
|
|
|
|
|
|
|
} |
143
|
1
|
|
|
|
|
34
|
}; |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
if (defined $err) { |
146
|
7
|
|
|
|
|
49
|
say STDERR "Oops! $err"; |
147
|
|
|
|
|
|
|
return; |
148
|
|
|
|
|
|
|
} |
149
|
0
|
|
|
|
|
0
|
|
150
|
|
|
|
|
|
|
1; |
151
|
48
|
|
|
|
|
488
|
} |
152
|
|
|
|
|
|
|
|
153
|
48
|
100
|
|
|
|
75266
|
my ($self, $cmd_class) = @_; |
154
|
8
|
|
|
|
|
48
|
for my $cmd (@{$self->deleted_commands}) { |
155
|
8
|
|
|
|
|
405
|
return 1 if $cmd_class->isa($cmd); |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
return; |
158
|
40
|
|
|
|
|
1228
|
} |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
1; |
161
|
|
|
|
|
|
|
|
162
|
624
|
|
|
624
|
0
|
76818
|
|
163
|
624
|
|
|
|
|
773
|
=pod |
|
624
|
|
|
|
|
1141
|
|
164
|
4368
|
50
|
|
|
|
14086
|
|
165
|
|
|
|
|
|
|
=head1 NAME |
166
|
624
|
|
|
|
|
1306
|
|
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 |