Rubric/CLI/Command/db.pm untested

filter: Statementstmt 0.0% 0 / 25 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 43 CC 4 SCAR 17.0
CC
4
Cov
0%
run
12.0
validate_args
6.0
usage_desc
2.0
CRAP 5.5
1 use strict;
2 use warnings;
3 package Rubric::CLI::Command::db 0.157;
4 # ABSTRACT: database management
5  
6 use parent qw(Rubric::CLI::Command);
7  
8 use Rubric::DBI::Setup;
9  
10 sub usage_desc { "rubric database %o" }
11  
12 sub opt_spec {
13 return (
14 [ mode => hidden => {
15 one_of => [
16 [ "setup|s", "set up a new database" ],
17 [ "update|u", "update your database schema" ],
18 ],
19 }
20 ],
21 );
22 }
23  
24 sub validate_args {
25 my ($self, $opt, $arg) = @_;
26  
27 die $self->usage->text unless $opt->{mode};
28 }
29  
30 sub run {
31 my ($self, $opt, $arg) = @_;
32  
33 if ($opt->{mode} eq 'setup') {
34 Rubric::DBI::Setup->setup_tables;
35 } elsif ($opt->{mode} eq 'update') {
36 Rubric::DBI::Setup->update_schema;
37 }
38 }
39  
40 1;
41  
42 __END__