line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use Catmandu::Sane; |
3
|
14
|
|
|
14
|
|
147862
|
|
|
14
|
|
|
|
|
28
|
|
|
14
|
|
|
|
|
87
|
|
4
|
|
|
|
|
|
|
our $VERSION = '1.2019'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use parent 'Catmandu::Cmd'; |
7
|
14
|
|
|
14
|
|
94
|
use Catmandu; |
|
14
|
|
|
|
|
28
|
|
|
14
|
|
|
|
|
72
|
|
8
|
14
|
|
|
14
|
|
880
|
use Catmandu::Util qw(require_package); |
|
14
|
|
|
|
|
46
|
|
|
14
|
|
|
|
|
66
|
|
9
|
14
|
|
|
14
|
|
2815
|
use namespace::clean; |
|
14
|
|
|
|
|
28
|
|
|
14
|
|
|
|
|
662
|
|
10
|
14
|
|
|
14
|
|
86
|
|
|
14
|
|
|
|
|
26
|
|
|
14
|
|
|
|
|
85
|
|
11
|
|
|
|
|
|
|
( |
12
|
|
|
|
|
|
|
["var=s%", ""], |
13
|
|
|
|
|
|
|
["fix=s@", ""], |
14
|
1
|
|
|
1
|
1
|
28
|
["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
|
|
|
10
|
$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
|
|
|
|
8
|
|
33
|
|
|
|
|
|
|
my $from = Catmandu->importer('Null'); |
34
|
1
|
|
|
|
|
3
|
$from = $self->_build_fixer($opts)->fix($from); |
35
|
|
|
|
|
|
|
|
36
|
1
|
|
|
|
|
9
|
if ($opts->verbose) { |
37
|
1
|
|
|
|
|
35
|
$from = $from->benchmark; |
38
|
|
|
|
|
|
|
} |
39
|
1
|
50
|
|
|
|
48
|
|
40
|
0
|
|
|
|
|
0
|
my $into = Catmandu->exporter('Null'); |
41
|
|
|
|
|
|
|
my $n = $into->add_many($from); |
42
|
|
|
|
|
|
|
$into->commit; |
43
|
1
|
|
|
|
|
11
|
|
44
|
1
|
|
|
|
|
14
|
if ($opts->verbose) { |
45
|
1
|
|
|
|
|
20
|
say STDERR $n == 1 ? "converted 1 item" : "converted $n items"; |
46
|
|
|
|
|
|
|
say STDERR "done"; |
47
|
1
|
50
|
|
|
|
8
|
} |
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 |