| 1 | package Catmandu::Cmd::convert; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 13 | ▶ | use Catmandu::Sane; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 13 | our $VERSION = '1.0201_02'; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 13 | ▶ | use parent 'Catmandu::Cmd'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 13 | ▶ | use Catmandu; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 13 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | sub command_opt_spec { | ||||||||||||||||||||||||||||
| 12 | ( | ||||||||||||||||||||||||||||
| 13 | 13 | ▶ | ["verbose|v", ""], | ||||||||||||||||||||||||||
|
Subroutine
command_opt_spec: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 14 | ["fix=s@", ""], | ||||||||||||||||||||||||||||
| 15 | ["var=s%", ""], | ||||||||||||||||||||||||||||
| 16 | ["preprocess|pp", ""], | ||||||||||||||||||||||||||||
| 17 | ["start=i", ""], | ||||||||||||||||||||||||||||
| 18 | ["total=i", ""], | ||||||||||||||||||||||||||||
| 19 | ); | ||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | sub command { | ||||||||||||||||||||||||||||
| 23 | 9 | ▶ | my ($self, $opts, $args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
command: called CC=7 SCAR=23.0
Pod
documented
| |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 9 | my ($from_args, $from_opts, $into_args, $into_opts) | |||||||||||||||||||||||||||
| 26 | = $self->_parse_options($args); | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 9 | my $from = Catmandu->importer($from_args->[0], $from_opts); | |||||||||||||||||||||||||||
| 29 | 8 | my $into = Catmandu->exporter($into_args->[0], $into_opts); | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 7 | ▶ | if ($opts->start // $opts->total) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$opts->start // $opts->total
MC/DC0%0/2
$opts->start // $opts->total
$opts->start
$opts->total
Truth table33%1/3
A // B
A= $opts->startB= $opts->total
| |||||||||||||||||||||||||||||
| 32 | 0 | $from = $from->slice($opts->start, $opts->total); | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | 7 | ▶ | if ($opts->fix) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | 4 | $from = $self->_build_fixer($opts)->fix($from); | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | 4 | ▶ | if ($opts->verbose) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | 0 | $from = $from->benchmark; | |||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 4 | my $n = $into->add_many($from); | |||||||||||||||||||||||||||
| 42 | 3 | $into->commit; | |||||||||||||||||||||||||||
| 43 | 3 | ▶ | if ($opts->verbose) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | 0 | ▶ | say STDERR $n == 1 ? "converted 1 object" : "converted $n objects"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | 0 | say STDERR "done"; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 13 | 1; | |||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | __END__ | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | =pod | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | =head1 NAME | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | Catmandu::Cmd::convert - convert objects | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | =head1 EXAMPLES | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | catmandu convert <IMPORTER> <OPTIONS> to <EXPORTER> <OPTIONS> | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | cat books.json | catmandu convert JSON to CSV --fields id,title | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | catmandu help importer JSON | ||||||||||||||||||||||||||||
| 66 | catmandu help exporter YAML | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | =cut | ||||||||||||||||||||||||||||