| 1 | package Catmandu::Cmd::export; | ||||||||||||||||||||||||||||||||
| 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 | 1 | ▶ | ["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 | ["limit=i", ""], | ||||||||||||||||||||||||||||||||
| 19 | ["total=i", ""], | ||||||||||||||||||||||||||||||||
| 20 | ["cql-query|q=s", ""], | ||||||||||||||||||||||||||||||||
| 21 | ["query=s", ""], | ||||||||||||||||||||||||||||||||
| 22 | ); | ||||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||
| 25 | sub command { | ||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | my ($self, $opts, $args) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
command: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||
| 28 | 0 | my ($from_args, $from_opts, $into_args, $into_opts) | |||||||||||||||||||||||||||||||
| 29 | = $self->_parse_options($args); | ||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||
| 31 | 0 | my $from_bag = delete $from_opts->{bag}; | |||||||||||||||||||||||||||||||
| 32 | 0 | my $from = Catmandu->store($from_args->[0], $from_opts)->bag($from_bag); | |||||||||||||||||||||||||||||||
| 33 | 0 | my $into = Catmandu->exporter($into_args->[0], $into_opts); | |||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | if ($opts->query // $opts->cql_query) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$opts->query // $opts->cql_query
MC/DC0%0/2
$opts->query // $opts->cql_query
$opts->query
$opts->cql_query
Truth table0%0/3
A // B
A= $opts->queryB= $opts->cql_query
| |||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | $self->usage_error("Bag isn't searchable") | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 37 | unless $from->can('searcher'); | ||||||||||||||||||||||||||||||||
| 38 | 0 | $from = $from->searcher( | |||||||||||||||||||||||||||||||
| 39 | cql_query => $opts->cql_query, | ||||||||||||||||||||||||||||||||
| 40 | query => $opts->query, | ||||||||||||||||||||||||||||||||
| 41 | start => $opts->start, | ||||||||||||||||||||||||||||||||
| 42 | total => $opts->total, | ||||||||||||||||||||||||||||||||
| 43 | limit => $opts->limit, | ||||||||||||||||||||||||||||||||
| 44 | ); | ||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||
| 46 | ▶ | elsif ($opts->start // $opts->total) { | |||||||||||||||||||||||||||||||
|
Condition0%0/3
$opts->start // $opts->total
MC/DC0%0/2
$opts->start // $opts->total
$opts->start
$opts->total
Truth table0%0/3
A // B
A= $opts->startB= $opts->total
| |||||||||||||||||||||||||||||||||
| 47 | 0 | $from = $from->slice($opts->start, $opts->total); | |||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | if ($opts->fix) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 50 | 0 | $from = $self->_build_fixer($opts)->fix($from); | |||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | if ($opts->verbose) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 53 | 0 | $from = $from->benchmark; | |||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||
| 56 | 0 | my $n = $into->add_many($from); | |||||||||||||||||||||||||||||||
| 57 | 0 | $into->commit; | |||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | if ($opts->verbose) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | say STDERR $n == 1 ? "exported 1 object" : "exported $n objects"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 60 | 0 | say STDERR "done"; | |||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||
| 64 | 13 | 1; | |||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||
| 66 | __END__ | ||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||
| 68 | =pod | ||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||
| 70 | =head1 NAME | ||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||
| 72 | Catmandu::Cmd::export - export objects from a store | ||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||
| 74 | =head1 EXAMPLES | ||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||
| 76 | catmandu export <STORE> <OPTIONS> to <EXPORTER> <OPTIONS> | ||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||
| 78 | catmandu export MongoDB --database-name items --bag book to YAML | ||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||
| 80 | catmandu help store MongoDB | ||||||||||||||||||||||||||||||||
| 81 | catmandu help exporter YAML | ||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||
| 83 | =cut | ||||||||||||||||||||||||||||||||