bin/cobalt2-dbdump

filter: Statementstmt 81.8% 9 / 11 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 86.6% 13 / 15 CC 1 SCAR 0.7
CC
1
Cov
82%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« blib/lib/Bot/Cobalt/Plugin/Master.pm ↑ Summary blib/lib/Bot/Cobalt/Plugin/Info3.pm »
1 #!perl
2  
3 1 ▶use 5.10.1;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 $|++;
8  
9 0 ▶use Bot::Cobalt::DB;
Subroutine BEGIN: called CC=1 SCAR=2.6
10 use Bot::Cobalt::Serializer;
11  
12 my($dbpath, $outpath);
13  
14 my $format = 'YAMLXS';
15  
16 use Getopt::Long;
17 GetOptions(
18 help => sub {
19 say "Usage: $0 --database=PATH --output=PATH [ --format=TYPE ]";
20 exit 0
21 },
22
23 'database=s' => \$dbpath,
24 'input=s' => \$dbpath,
25
26 'output=s' => \$outpath,
27
28 'format=s' => \$format,
29 );
30  
31 ## Format check
32 die "$format is not a valid export format; see perldoc Bot::Cobalt::Serializer"
33 unless Bot::Cobalt::Serializer->new->_check_if_avail($format);
34  
35 unless ($dbpath) {
36 print "Path to database to be exported: \n > ";
37 $dbpath = <STDIN>;
38 chomp($dbpath);
39 }
40  
41 die "could not locate dbpath: $dbpath"
42 unless -f $dbpath;
43  
44 unless ($outpath) {
45 print "Output path: \n > ";
46 $outpath = <STDIN>;
47 chomp($outpath);
48 }
49  
50 if (-f $outpath) {
51 print "Output path exists...\n";
52 print "Press ENTER to continue, Ctrl+C to exit. ";
53 <STDIN>;
54 print "\n";
55 }
56  
57 my $db = Bot::Cobalt::DB->new(
58 file => $dbpath,
59 );
60  
61 $db->dbopen(ro => 1) or die "dbopen failure";
62 my $yaml = $db->dbdump($format) or die "dbdump failure";
63 $db->dbclose;
64  
65 say "Writing $format to $outpath";
66  
67 open my $outfh, '>:encoding(UTF-8)', $outpath or die "open failed: $!";
68 print $outfh $yaml;
69 close $outfh;
70  
71 say "Done.";
72  
73 __END__
« blib/lib/Bot/Cobalt/Plugin/Master.pm ↑ Summary blib/lib/Bot/Cobalt/Plugin/Info3.pm »