line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use Catmandu::Sane; |
3
|
14
|
|
|
14
|
|
137428
|
|
|
14
|
|
|
|
|
30
|
|
|
14
|
|
|
|
|
75
|
|
4
|
|
|
|
|
|
|
our $VERSION = '1.2018'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use parent 'Catmandu::Cmd'; |
7
|
14
|
|
|
14
|
|
87
|
use Catmandu; |
|
14
|
|
|
|
|
28
|
|
|
14
|
|
|
|
|
69
|
|
8
|
14
|
|
|
14
|
|
851
|
use Catmandu::Util qw(require_package); |
|
14
|
|
|
|
|
28
|
|
|
14
|
|
|
|
|
70
|
|
9
|
14
|
|
|
14
|
|
2629
|
use namespace::clean; |
|
14
|
|
|
|
|
34
|
|
|
14
|
|
|
|
|
597
|
|
10
|
14
|
|
|
14
|
|
69
|
|
|
14
|
|
|
|
|
31
|
|
|
14
|
|
|
|
|
86
|
|
11
|
|
|
|
|
|
|
( |
12
|
|
|
|
|
|
|
["var=s%", ""], |
13
|
|
|
|
|
|
|
["fix=s@", ""], |
14
|
1
|
|
|
1
|
1
|
16
|
["preprocess|pp", ""], |
15
|
|
|
|
|
|
|
["verbose|v", ""], |
16
|
|
|
|
|
|
|
["i", "interactive mode"], |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my ($self, $opts, $args) = @_; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
if (defined $opts->{i} || !defined $args->[0]) { |
23
|
1
|
|
|
1
|
1
|
3
|
my $pkg = require_package('Catmandu::Interactive'); |
24
|
|
|
|
|
|
|
my $app = Catmandu::Interactive->new(); |
25
|
1
|
50
|
33
|
|
|
18
|
$app->run(); |
26
|
0
|
|
|
|
|
0
|
} |
27
|
0
|
|
|
|
|
0
|
else { |
28
|
0
|
|
|
|
|
0
|
my $fix_file = $args->[0]; |
29
|
|
|
|
|
|
|
$fix_file = [\*STDIN] unless defined $fix_file; |
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
3
|
$opts->{fix} = [$fix_file]; |
32
|
1
|
50
|
|
|
|
7
|
|
33
|
|
|
|
|
|
|
my $from = Catmandu->importer('Null'); |
34
|
1
|
|
|
|
|
3
|
$from = $self->_build_fixer($opts)->fix($from); |
35
|
|
|
|
|
|
|
|
36
|
1
|
|
|
|
|
7
|
if ($opts->verbose) { |
37
|
1
|
|
|
|
|
20
|
$from = $from->benchmark; |
38
|
|
|
|
|
|
|
} |
39
|
1
|
50
|
|
|
|
43
|
|
40
|
0
|
|
|
|
|
0
|
my $into = Catmandu->exporter('Null'); |
41
|
|
|
|
|
|
|
my $n = $into->add_many($from); |
42
|
|
|
|
|
|
|
$into->commit; |
43
|
1
|
|
|
|
|
12
|
|
44
|
1
|
|
|
|
|
10
|
if ($opts->verbose) { |
45
|
1
|
|
|
|
|
29
|
say STDERR $n == 1 ? "converted 1 item" : "converted $n items"; |
46
|
|
|
|
|
|
|
say STDERR "done"; |
47
|
1
|
50
|
|
|
|
6
|
} |
48
|
0
|
0
|
|
|
|
|
} |
49
|
0
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=pod |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 NAME |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Catmandu::Cmd::run - run a fix command |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 EXAMPLES |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# Run an interactive Fix shell |
63
|
|
|
|
|
|
|
$ catmandu run |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# Execute the fix script |
66
|
|
|
|
|
|
|
$ catmandu run myfixes.txt |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# Execute the scripts with options passed |
69
|
|
|
|
|
|
|
$ catmandu run --var source=bla myfixes.txt |
70
|
|
|
|
|
|
|
$ cat myfixes.txt |
71
|
|
|
|
|
|
|
add_field(my_source,{{source}}) |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# Or create an execurable fix script: |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
#!/usr/bin/env catmandu run |
76
|
|
|
|
|
|
|
do importer(Mock,size:10) |
77
|
|
|
|
|
|
|
add_field(foo,bar) |
78
|
|
|
|
|
|
|
add_to_exporter(.,JSON) |
79
|
|
|
|
|
|
|
end |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=cut |