| 1 | package Catmandu::Cmd::data; | ||||||||||||||||||||||||||||||||
| 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 | ▶ | ["from-store=s", "", {default => Catmandu->default_store}], | ||||||||||||||||||||||||||||||
|
Subroutine
command_opt_spec: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 14 | ["from-importer=s", ""], | ||||||||||||||||||||||||||||||||
| 15 | ["from-bag=s", ""], | ||||||||||||||||||||||||||||||||
| 16 | ["count", ""], | ||||||||||||||||||||||||||||||||
| 17 | ["into-exporter=s", ""], | ||||||||||||||||||||||||||||||||
| 18 | ["into-store=s", "", {default => Catmandu->default_store}], | ||||||||||||||||||||||||||||||||
| 19 | ["into-bag=s", ""], | ||||||||||||||||||||||||||||||||
| 20 | ["start=i", ""], | ||||||||||||||||||||||||||||||||
| 21 | ["limit=i", ""], | ||||||||||||||||||||||||||||||||
| 22 | ["total=i", ""], | ||||||||||||||||||||||||||||||||
| 23 | ["cql-query|q=s", ""], | ||||||||||||||||||||||||||||||||
| 24 | ["query=s", ""], | ||||||||||||||||||||||||||||||||
| 25 | ["fix=s@", "fix expression(s) or fix file(s)"], | ||||||||||||||||||||||||||||||||
| 26 | ["var=s%", ""], | ||||||||||||||||||||||||||||||||
| 27 | ["preprocess|pp", ""], | ||||||||||||||||||||||||||||||||
| 28 | ["replace", ""], | ||||||||||||||||||||||||||||||||
| 29 | ["verbose|v", ""], | ||||||||||||||||||||||||||||||||
| 30 | ); | ||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||
| 33 | sub command { | ||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | my ($self, $opts, $args) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
command: not called CC=20 SCAR=60.4
Pod
documented
| |||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||
| 36 | 0 | my $from_opts = {}; | |||||||||||||||||||||||||||||||
| 37 | 0 | my $into_opts = {}; | |||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | for (my $i = 0; $i < @$args; $i++) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 39 | 0 | my $arg = $args->[$i]; | |||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | if (my ($for, $key) = $arg =~ /^--(from|into)-([\w\-]+)$/) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | if (defined(my $val = $args->[++$i])) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 42 | 0 | $key =~ s/-/_/g; | |||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | ($for eq 'from' ? $from_opts : $into_opts)->{$key} = $val; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||
| 48 | 0 | my $from; | |||||||||||||||||||||||||||||||
| 49 | my $into; | ||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | if ($opts->from_bag) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 52 | 0 | $from = Catmandu->store($opts->from_store, $from_opts) | |||||||||||||||||||||||||||||||
| 53 | ->bag($opts->from_bag); | ||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||
| 55 | else { | ||||||||||||||||||||||||||||||||
| 56 | 0 | $from = Catmandu->importer($opts->from_importer, $from_opts); | |||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | if ($opts->query || $opts->cql_query) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$opts->query or $opts->cql_query
MC/DC0%0/2
$opts->query or $opts->cql_query
$opts->query
$opts->cql_query
Truth table0%0/3
A or B
A= $opts->queryB= $opts->cql_query
| |||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | $self->usage_error("Bag isn't searchable") | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 61 | unless $from->can('searcher'); | ||||||||||||||||||||||||||||||||
| 62 | 0 | $from = $from->searcher( | |||||||||||||||||||||||||||||||
| 63 | cql_query => $opts->cql_query, | ||||||||||||||||||||||||||||||||
| 64 | query => $opts->query, | ||||||||||||||||||||||||||||||||
| 65 | limit => $opts->limit, | ||||||||||||||||||||||||||||||||
| 66 | ); | ||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||
| 68 | elsif (defined $opts->limit) { | ||||||||||||||||||||||||||||||||
| 69 | 0 | $from = $from->take($opts->limit); | |||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | if ($opts->start || defined $opts->total) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$opts->start or defined $opts->total
MC/DC0%0/2
$opts->start or defined $opts->total
$opts->start
defined $opts->total
Truth table0%0/3
A or B
A= $opts->startB= defined $opts->total
| |||||||||||||||||||||||||||||||||
| 73 | 0 | $from = $from->slice($opts->start, $opts->total); | |||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | if ($opts->count) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 77 | 0 | return say $from->count; | |||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | if ($opts->into_bag) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 81 | 0 | $into = Catmandu->store($opts->into_store, $into_opts) | |||||||||||||||||||||||||||||||
| 82 | ->bag($opts->into_bag); | ||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||
| 84 | else { | ||||||||||||||||||||||||||||||||
| 85 | 0 | $into = Catmandu->exporter($opts->into_exporter, $into_opts); | |||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | if ($opts->fix) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 89 | 0 | $from = $self->_build_fixer($opts)->fix($from); | |||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | if ($opts->replace && $into->can('delete_all')) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$opts->replace and $into->can("delete_all")
MC/DC0%0/2
$opts->replace and $into->can("delete_all")
$opts->replace
$into->can("delete_all")
Truth table0%0/3
A and B
A= $opts->replaceB= $into->can("delete_all")
| |||||||||||||||||||||||||||||||||
| 93 | 0 | $into->delete_all; | |||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | if ($opts->verbose) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 97 | 0 | $from = $from->benchmark; | |||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||
| 100 | 0 | my $n = $into->add_many($from); | |||||||||||||||||||||||||||||||
| 101 | 0 | $into->commit; | |||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | if ($opts->verbose) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | say STDERR $n == 1 ? "added 1 object" : "added $n objects"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 105 | 0 | say STDERR "done"; | |||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||
| 109 | 13 | 1; | |||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||
| 111 | __END__ | ||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||
| 113 | =pod | ||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||
| 115 | =head1 NAME | ||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||
| 117 | Catmandu::Cmd::data - store, index, search, import, export or convert (deprecated) | ||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||
| 119 | =head1 DEPRECIATION NOTICE | ||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||
| 121 | This fix is deprecated, Please use these commands instead: | ||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||
| 123 | =over 4 | ||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||
| 125 | =item L<Catmandu::Cmd::convert> | ||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||
| 127 | =item L<Catmandu::Cmd::copy> | ||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||
| 129 | =item L<Catmandu::Cmd::import> | ||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||
| 131 | =item L<Catmandu::Cmd::export> | ||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||
| 133 | =item L<Catmandu::Cmd::count> | ||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||
| 135 | =item L<Catmandu::Cmd::delete> | ||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||
| 137 | =back | ||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||
| 139 | =cut | ||||||||||||||||||||||||||||||||