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

filter: Statementstmt 100% 35 / 35 Branchbran 60.0% 6 / 10 Conditioncond 37.5% 6 / 16 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 69.3% 52 / 75 CC 15 SCAR 28.2
CC
15
Cov
77%
execute
20.9
BEGIN
1.0
BEGIN
1.0
CRAP 16.7
« lib/WWW/Hetzner/CLI/Cmd/FloatingIp/Cmd/Describe.pm ↑ Summary lib/WWW/Hetzner/Robot/CLI/Cmd/Boot/Cmd/Vnc.pm »
1 package WWW::Hetzner::CLI::Cmd::StorageBox::Cmd::Describe;
2 # ABSTRACT: Describe 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 describe <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  
11 2 ▶sub execute {
Subroutine execute: called CC=15 SCAR=30.4
Pod undocumented
12 2 my ($self, $args, $chain) = @_;
13 2 ▶ my $id = $args->[0] or die "Usage: hcloud.pl storage-box describe <storage-box>\n";
Branch: 1 branch
BranchTrueFalseTotal
my $id = $args->[0] or die "Usage: hcloud.pl storage-box describe <storage-box>\n" 2 0 2
14 2 my $main = $chain->[0];
15 2 my $box = $main->storage->storage_boxes->get($id);
16  
17 2 ▶ if ($main->output eq 'json') {
Branch: 1 branch
BranchTrueFalseTotal
if ($main->output eq "json") 1 1 2
18 1 print encode_json($box->data), "\n";
19 1 return;
20 }
21  
22 1 my $type = $box->storage_box_type;
23 1 my $location = $box->location;
24 1 print "Storage Box:\n";
25 1 printf " ID: %s\n", $box->id;
26 1 printf " Name: %s\n", $box->name;
27 1 ▶ printf " Type: %s\n", ref $type eq 'HASH' ? ($type->{name} // '-') : ($type // '-');
Branch: 1 branch
BranchTrueFalseTotal
ref $type eq 'HASH' ? : 1 0 1
Condition25%1/4
$type->{"name"} // "-"
l!l
10
$type // "-"
l!l
00
MC/DC0%0/1
$type->{"name"} // "-"
$type->{"name"}
MC/DC0%0/1
$type // "-"
$type
Truth table50%1/2
A
A= $type->{"name"}
Aresult
11
00
Truth table0%0/2
A
A= $type
Aresult
11
00
28 1 ▶ printf " Location: %s\n", ref $location eq 'HASH' ? ($location->{name} // '-') : ($location // '-');
Branch: 1 branch
BranchTrueFalseTotal
ref $location eq 'HASH' ? : 1 0 1
Condition25%1/4
$location->{"name"} // "-"
l!l
10
$location // "-"
l!l
00
MC/DC0%0/1
$location->{"name"} // "-"
$location->{"name"}
MC/DC0%0/1
$location // "-"
$location
Truth table50%1/2
A
A= $location->{"name"}
Aresult
11
00
Truth table0%0/2
A
A= $location
Aresult
11
00
29 1 ▶ printf " Status: %s\n", $box->status // '-';
Condition50%1/2
$box->status // "-"
l!l
10
MC/DC0%0/1
$box->status // "-"
$box->status
Truth table50%1/2
A
A= $box->status
Aresult
11
00
30 1 ▶ printf " Username: %s\n", $box->username // '-';
Condition50%1/2
$box->username // "-"
l!l
10
MC/DC0%0/1
$box->username // "-"
$box->username
Truth table50%1/2
A
A= $box->username
Aresult
11
00
31 1 ▶ printf " Server: %s\n", $box->server // '-';
Condition50%1/2
$box->server // "-"
l!l
01
MC/DC0%0/1
$box->server // "-"
$box->server
Truth table50%1/2
A
A= $box->server
Aresult
11
00
32 1 ▶ my $labels = $box->labels // {};
Condition50%1/2
$box->labels // {}
l!l
10
MC/DC0%0/1
$box->labels // {}
$box->labels
Truth table50%1/2
A
A= $box->labels
Aresult
11
00
33 1 ▶ if (%$labels) {
Branch: 1 branch
BranchTrueFalseTotal
if (%$labels) 1 0 1
34 1 print " Labels:\n";
35 1 printf " %s: %s\n", $_, $labels->{$_} for sort keys %$labels;
36 }
37 }
38  
39 1 1;
40  
41 __END__
« lib/WWW/Hetzner/CLI/Cmd/FloatingIp/Cmd/Describe.pm ↑ Summary lib/WWW/Hetzner/Robot/CLI/Cmd/Boot/Cmd/Vnc.pm »