line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Cmd::count; |
2
|
|
|
|
|
|
|
|
3
|
14
|
|
|
14
|
|
135677
|
use Catmandu::Sane; |
|
14
|
|
|
|
|
47
|
|
|
14
|
|
|
|
|
89
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.2020'; |
6
|
|
|
|
|
|
|
|
7
|
14
|
|
|
14
|
|
120
|
use parent 'Catmandu::Cmd'; |
|
14
|
|
|
|
|
37
|
|
|
14
|
|
|
|
|
76
|
|
8
|
14
|
|
|
14
|
|
1009
|
use Catmandu; |
|
14
|
|
|
|
|
47
|
|
|
14
|
|
|
|
|
74
|
|
9
|
14
|
|
|
14
|
|
2943
|
use namespace::clean; |
|
14
|
|
|
|
|
39
|
|
|
14
|
|
|
|
|
83
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub command_opt_spec { |
12
|
1
|
|
|
1
|
1
|
13
|
(["cql-query|q=s", ""], ["query=s", ""],); |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub command { |
16
|
1
|
|
|
1
|
1
|
4
|
my ($self, $opts, $args) = @_; |
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
|
|
17
|
my ($from_args, $from_opts) = $self->_parse_options($args); |
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
|
|
4
|
my $from_bag = delete $from_opts->{bag}; |
21
|
1
|
|
|
|
|
9
|
my $from = Catmandu->store($from_args->[0], $from_opts)->bag($from_bag); |
22
|
|
|
|
|
|
|
|
23
|
1
|
50
|
33
|
|
|
8
|
if ($opts->query // $opts->cql_query) { |
24
|
0
|
0
|
|
|
|
0
|
$self->usage_error("Bag isn't searchable") |
25
|
|
|
|
|
|
|
unless $from->can('searcher'); |
26
|
0
|
|
|
|
|
0
|
$from = $from->searcher( |
27
|
|
|
|
|
|
|
cql_query => $opts->cql_query, |
28
|
|
|
|
|
|
|
query => $opts->query, |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
1
|
|
|
|
|
18
|
say $from->count; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
1; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
__END__ |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=pod |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 NAME |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Catmandu::Cmd::count - count the number of items in a bag |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 EXAMPLES |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
catmandu count <STORE> <OPTIONS> |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
catmandu count ElasticSearch --index-name shop --bag products \ |
50
|
|
|
|
|
|
|
--query 'brand:Acme' |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
catmandu help store ElasticSearch |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 SEE ALSO |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
To count the number of items from an importer, use L<Catmandu::Exporter::Count>. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |