lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Snapshot.pm

filter: Statementstmt 85.2% 29 / 34 Branchbran 62.5% 5 / 8 Conditioncond 50.0% 3 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 1 totaltotal 74.5% 44 / 59 CC 9 SCAR 21.3
CC
9
Cov
77%
_list
13.4
BEGIN
1.0
BEGIN
1.0
CRAP 8.5
« lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Snapshot/Cmd/RemoveLabel.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/Zone/Cmd/Describe.pm »
1 package WWW::Hetzner::CLI::Cmd::StorageBox::Cmd::Snapshot;
2 # ABSTRACT: Storage Box snapshot commands
3  
4 1 our $VERSION = '0.102';
5  
6 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use MooX::Cmd;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use MooX::Options protect_argv => 0, usage_string => 'USAGE: hcloud.pl storage-box snapshot <command> [options] <storage-box>';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use JSON::MaybeXS qw(encode_json);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use WWW::Hetzner::Storage::API::Snapshots;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12  
13 1 ▶sub execute {
Subroutine execute: called CC=1 SCAR=0.0
Pod undocumented
14 1 my ($self, $args, $chain) = @_;
15 1 $self->_list($args, $chain);
16 }
17  
18 1 ▶sub _list {
Subroutine _list: called CC=9 SCAR=26.0
19 1 my ($self, $args, $chain) = @_;
20 1 ▶ my $id = $args->[0] or die "Usage: hcloud.pl storage-box snapshot list <storage-box>\n";
Branch: 1 branch
BranchTrueFalseTotal
my $id = $args->[0] or die "Usage: hcloud.pl storage-box snapshot list <storage-box>\n" 1 0 1
21 1 my $main = $chain->[0];
22 1 my $snapshots = WWW::Hetzner::Storage::API::Snapshots->new(
23 client => $main->storage,
24 storage_box_id => $id,
25 )->list;
26  
27 1 ▶ if ($main->output eq 'json') {
Branch: 1 branch
BranchTrueFalseTotal
if ($main->output eq "json") 0 1 1
28 0 print encode_json([map { $_->data } @$snapshots]), "\n";
29 0 return;
30 }
31  
32 1 ▶ if (!@$snapshots) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@$snapshots) 0 1 1
33 0 print "No snapshots found.\n";
34 0 return;
35 }
36  
37 1 printf "%-10s %-30s %-25s %s\n", 'ID', 'NAME', 'DESCRIPTION', 'CREATED';
38 1 print '-' x 90, "\n";
39 1 for my $snap (@$snapshots) {
40 2 ▶ printf "%-10s %-30s %-25s %s\n",
Branch: 1 branch
BranchTrueFalseTotal
($snap->description // '') ne '' ? : 1 1 2
Condition50%3/6
$snap->name // "-"
l!l
20
$snap->description // ""
l!l
20
$snap->created // "-"
l!l
20
MC/DC0%0/1
$snap->name // "-"
$snap->name
MC/DC0%0/1
$snap->description // ""
$snap->description
MC/DC0%0/1
$snap->created // "-"
$snap->created
Truth table50%1/2
A
A= $snap->name
Aresult
11
00
Truth table50%1/2
A
A= $snap->description
Aresult
11
00
Truth table50%1/2
A
A= $snap->created
Aresult
11
00
41 $snap->id,
42 $snap->name // '-',
43 ($snap->description // '') ne '' ? $snap->description : '-',
44 $snap->created // '-';
45 }
46 }
47  
48  
49 1 1;
50  
51 __END__
« lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Snapshot/Cmd/RemoveLabel.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/Zone/Cmd/Describe.pm »