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

filter: Statementstmt 84.3% 27 / 32 Branchbran 62.5% 5 / 8 Conditioncond 50.0% 3 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 73.2% 41 / 56 CC 9 SCAR 22.0
CC
9
Cov
76%
execute
13.4
BEGIN
1.0
BEGIN
1.0
CRAP 9.0
« lib/WWW/Hetzner/CLI/Cmd/Certificate/Cmd/Describe.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Snapshot/Cmd/Describe.pm »
1 package WWW::Hetzner::CLI::Cmd::StorageBox::Cmd::Snapshot::Cmd::List;
2 # ABSTRACT: List snapshots of a Storage Box
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 list <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=9 SCAR=26.0
Pod undocumented
14 1 my ($self, $args, $chain) = @_;
15 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
16 1 my $main = $chain->[0];
17 1 my $snapshots = WWW::Hetzner::Storage::API::Snapshots->new(
18 client => $main->storage,
19 storage_box_id => $id,
20 )->list;
21  
22 1 ▶ if ($main->output eq 'json') {
Branch: 1 branch
BranchTrueFalseTotal
if ($main->output eq "json") 0 1 1
23 0 print encode_json([map { $_->data } @$snapshots]), "\n";
24 0 return;
25 }
26  
27 1 ▶ if (!@$snapshots) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@$snapshots) 0 1 1
28 0 print "No snapshots found.\n";
29 0 return;
30 }
31  
32 1 printf "%-10s %-30s %-25s %s\n", 'ID', 'NAME', 'DESCRIPTION', 'CREATED';
33 1 print '-' x 90, "\n";
34 1 for my $snap (@$snapshots) {
35 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
36 $snap->id,
37 $snap->name // '-',
38 ($snap->description // '') ne '' ? $snap->description : '-',
39 $snap->created // '-';
40 }
41 }
42  
43 1 1;
44  
45 __END__
« lib/WWW/Hetzner/CLI/Cmd/Certificate/Cmd/Describe.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Snapshot/Cmd/Describe.pm »