blib/lib/Tapper/CLI/DbDeploy/Command/init.pm

filter: Statementstmt 55.3% 26 / 47 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 57.1% 8 / 14 Podpod 80.0% 4 / 5 totaltotal 52.7% 38 / 72 CC 4 SCAR 17.5
CC
4
Cov
49%
validate_args
20.0
opt_spec
2.0
abstract
2.0
CRAP 5.8
« blib/lib/Tapper/CLI/DbDeploy/Command/upgrade.pm ↑ Summary blib/lib/Tapper/CLI/Notification.pm »
1 package Tapper::CLI::DbDeploy::Command::init;
2 2 our $AUTHORITY = 'cpan:TAPPER';
3 2 $Tapper::CLI::DbDeploy::Command::init::VERSION = '5.0.8';
4 2 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 ▶use parent 'App::Cmd::Command';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 ▶use Tapper::CLI::DbDeploy;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use Tapper::Cmd::DbDeploy;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 ▶use Tapper::Schema::TestrunDB;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16  
17 0 ▶sub opt_spec {
Subroutine opt_spec: not called CC=1 SCAR=6.9
Pod documented
18 return (
19 0 [ "verbose", "some more informational output" ],
20 [ "db=s", "STRING, one of: ReportsDB, TestrunDB" ],
21 );
22 }
23  
24 0 ▶sub abstract {
Subroutine abstract: not called CC=1 SCAR=6.9
Pod documented
25 0 'Initialize a database from scratch. DANGEROUS! Think twice.'
26 }
27  
28 sub usage_desc
29 0 ▶{
Subroutine usage_desc: not called CC=1 SCAR=6.9
Pod documented
30 0 my ($self, $opt, $args) = @_;
31 0 my $allowed_opts = join ' ', map { '--'.$_ } $self->_allowed_opts();
32 0 "tapper-db-deploy init --db=DBNAME [ --verbose ]";
33 }
34  
35 0 ▶sub _allowed_opts {
Subroutine _allowed_opts: not called CC=1 SCAR=6.9
36 0 my ($self, $opt, $args) = @_;
37 0 my @allowed_opts = map { $_->[0] } $self->opt_spec();
38 }
39  
40 0 ▶sub validate_args {
Subroutine validate_args: not called CC=4 SCAR=30.0
Pod documented
41 0 my ($self, $opt, $args) = @_;
42  
43 # print "opt = ", Dumper($opt);
44 # print "args = ", Dumper($args);
45  
46 0 my $ok = 1;
47 0 ▶ if (not $opt->{db})
Branch: 2 branches
BranchTrueFalseTotal
if (not $opt->{'db'}) { } 0 0 0
elsif (not $opt->{'db'} = 'TestrunDB') { } 0 0 0
48 {
49 0 say "Missing argument --db\n";
50 0 $ok = 0;
51 }
52 elsif (not $opt->{db} = 'TestrunDB' )
53 {
54 0 say "Wrong DB name '".$opt->{db}."' (must be TestrunDB)";
55 0 $ok = 0;
56 }
57  
58 0 ▶ return $ok if $ok;
Branch: 1 branch
BranchTrueFalseTotal
if $ok 0 0 0
59 0 die $self->usage->text;
60 }
61  
62 sub run
63 0 ▶{
Subroutine run: not called CC=1 SCAR=6.9
Pod undocumented
64 0 my ($self, $opt, $args) = @_;
65  
66 0 my $cmd = Tapper::Cmd::DbDeploy->new;
67 0 $cmd->dbdeploy($opt->{db});
68 }
69  
70  
71 # perl -Ilib bin/tapper-db-deploy init --db=TestrunDB
72  
73 2 1;
74  
75 __END__
« blib/lib/Tapper/CLI/DbDeploy/Command/upgrade.pm ↑ Summary blib/lib/Tapper/CLI/Notification.pm »