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

filter: Statementstmt 100% 35 / 35 Branchbran 60.0% 6 / 10 Conditioncond 50.0% 4 / 8 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 79.6% 51 / 64 CC 11 SCAR 21.7
CC
11
Cov
85%
execute
12.3
BEGIN
1.0
BEGIN
1.0
CRAP 8.8
« lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Snapshot/Cmd/List.pm ↑ Summary lib/WWW/Hetzner/Robot/CLI/Cmd/Boot.pm »
1 package WWW::Hetzner::CLI::Cmd::StorageBox::Cmd::Snapshot::Cmd::Describe;
2 # ABSTRACT: Describe a Storage Box snapshot
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 describe <storage-box> <snapshot>';
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 2 ▶sub execute {
Subroutine execute: called CC=11 SCAR=25.1
Pod undocumented
14 2 my ($self, $args, $chain) = @_;
15 2 ▶ my $id = $args->[0] or die "Usage: hcloud.pl storage-box snapshot describe <storage-box> <snapshot>\n";
Branch: 1 branch
BranchTrueFalseTotal
my $id = $args->[0] or die "Usage: hcloud.pl storage-box snapshot describe <storage-box> <snapshot>\n" 2 0 2
16 2 ▶ my $snap = $args->[1] or die "Usage: hcloud.pl storage-box snapshot describe <storage-box> <snapshot>\n";
Branch: 1 branch
BranchTrueFalseTotal
my $snap = $args->[1] or die "Usage: hcloud.pl storage-box snapshot describe <storage-box> <snapshot>\n" 2 0 2
17 2 my $main = $chain->[0];
18 2 my $snapshots = WWW::Hetzner::Storage::API::Snapshots->new(
19 client => $main->storage,
20 storage_box_id => $id,
21 );
22 2 my $snapshot = $snapshots->get($snap);
23  
24 2 ▶ if ($main->output eq 'json') {
Branch: 1 branch
BranchTrueFalseTotal
if ($main->output eq "json") 1 1 2
25 1 print encode_json($snapshot->data), "\n";
26 1 return;
27 }
28  
29 1 print "Snapshot:\n";
30 1 printf " ID: %s\n", $snapshot->id;
31 1 ▶ printf " Name: %s\n", $snapshot->name // '-';
Condition50%1/2
$snapshot->name // "-"
l!l
10
MC/DC0%0/1
$snapshot->name // "-"
$snapshot->name
Truth table50%1/2
A
A= $snapshot->name
Aresult
11
00
32 1 ▶ printf " Description: %s\n", ($snapshot->description // '') ne '' ? $snapshot->description : '-';
Branch: 1 branch
BranchTrueFalseTotal
($snapshot->description // '') ne '' ? : 1 0 1
Condition50%1/2
$snapshot->description // ""
l!l
10
MC/DC0%0/1
$snapshot->description // ""
$snapshot->description
Truth table50%1/2
A
A= $snapshot->description
Aresult
11
00
33 1 ▶ printf " Created: %s\n", $snapshot->created // '-';
Condition50%1/2
$snapshot->created // "-"
l!l
10
MC/DC0%0/1
$snapshot->created // "-"
$snapshot->created
Truth table50%1/2
A
A= $snapshot->created
Aresult
11
00
34 1 ▶ my $labels = $snapshot->labels // {};
Condition50%1/2
$snapshot->labels // {}
l!l
10
MC/DC0%0/1
$snapshot->labels // {}
$snapshot->labels
Truth table50%1/2
A
A= $snapshot->labels
Aresult
11
00
35 1 ▶ if (%$labels) {
Branch: 1 branch
BranchTrueFalseTotal
if (%$labels) 1 0 1
36 1 print " Labels:\n";
37 1 printf " %s: %s\n", $_, $labels->{$_} for sort keys %$labels;
38 }
39 }
40  
41 1 1;
42  
43 __END__
« lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Snapshot/Cmd/List.pm ↑ Summary lib/WWW/Hetzner/Robot/CLI/Cmd/Boot.pm »