| 1 | package Catmandu::Cmd::delete; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 14 | ▶ | use Catmandu::Sane; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 14 | our $VERSION = '1.2025'; | |||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 14 | ▶ | use parent 'Catmandu::Cmd'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 14 | ▶ | use Catmandu; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | 14 | ▶ | use Catmandu::Util qw(check_able); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | 14 | ▶ | use namespace::clean; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 1 | ▶ | sub command_opt_spec { | ||||||||||||||||||
|
Subroutine
command_opt_spec: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 13 | 1 | (["cql-query|q=s", ""], ["query=s", ""], ["id=s@", ""],); | |||||||||||||||||||
| 14 | } | ||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 1 | ▶ | sub command { | ||||||||||||||||||
|
Subroutine
command: called CC=5 SCAR=19.7
Pod
documented
| |||||||||||||||||||||
| 17 | 1 | my ($self, $opts, $args) = @_; | |||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | 1 | my ($from_args, $from_opts) = $self->_parse_options($args); | |||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | 1 | my $from_bag = delete $from_opts->{bag}; | |||||||||||||||||||
| 22 | 1 | my $from = Catmandu->store($from_args->[0], $from_opts)->bag($from_bag); | |||||||||||||||||||
| 23 | 1 | ▶ | if ($opts->id) { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 24 | 0 | $from->delete($_) for @{$opts->id}; | |||||||||||||||||||
| 25 | } | ||||||||||||||||||||
| 26 | ▶ | elsif ($opts->query // $opts->cql_query) { | |||||||||||||||||||
|
Condition33%1/3
$opts->query // $opts->cql_query
MC/DC0%0/2
$opts->query // $opts->cql_query
$opts->query
$opts->cql_query
Truth table33%1/3
A // B
A= $opts->queryB= $opts->cql_query
| |||||||||||||||||||||
| 27 | 0 | check_able($from, 'delete_by_query'); | |||||||||||||||||||
| 28 | 0 | $from->delete_by_query( | |||||||||||||||||||
| 29 | cql_query => $opts->cql_query, | ||||||||||||||||||||
| 30 | query => $opts->query, | ||||||||||||||||||||
| 31 | ); | ||||||||||||||||||||
| 32 | } | ||||||||||||||||||||
| 33 | else { | ||||||||||||||||||||
| 34 | 1 | $from->delete_all; | |||||||||||||||||||
| 35 | } | ||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | 1 | $from->commit; | |||||||||||||||||||
| 38 | } | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | 14 | 1; | |||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | __END__ | ||||||||||||||||||||