File: drop.pm

package info (click to toggle)
libcatmandu-perl 1.2024-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,552 kB
  • sloc: perl: 17,037; makefile: 24; sh: 1
file content (49 lines) | stat: -rw-r--r-- 863 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package Catmandu::Cmd::drop;

use Catmandu::Sane;

our $VERSION = '1.2024';

use parent 'Catmandu::Cmd';
use Catmandu;
use Catmandu::Util qw(check_able);
use namespace::clean;

sub command_opt_spec {
    (["bag=s", "drop a bag"],);
}

sub command {
    my ($self, $opts, $args) = @_;

    my ($from_args, $from_opts) = $self->_parse_options($args);

    my $from = Catmandu->store($from_args->[0], $from_opts);
    if ($opts->bag) {
        check_able($from->bag($opts->bag), 'drop')->drop;
    }
    else {
        check_able($from, 'drop')->drop;
    }
}

1;

__END__

=pod

=head1 NAME

Catmandu::Cmd::drop - drop a store or one of its bags

=head1 EXAMPLES

  catmandu drop <STORE> <OPTIONS>

  # drop the whole store
  catmandu drop ElasticSearch --index-name items
  # drop a single bag
  catmandu drop ElasticSearch --index-name items --bag thingies

=cut