lib/WWW/Hetzner/CLI/Cmd/PlacementGroup/Cmd/List.pm

filter: Statementstmt 83.3% 25 / 30 Branchbran 50.0% 2 / 4 Conditioncond 50.0% 3 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 71.4% 35 / 49 CC 7 SCAR 18.9
CC
7
Cov
75%
execute
9.8
BEGIN
1.0
BEGIN
1.0
CRAP 6.6
« lib/WWW/Hetzner/CLI/Cmd/Network/Cmd/List.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Snapshot/Cmd/Update.pm »
1 package WWW::Hetzner::CLI::Cmd::PlacementGroup::Cmd::List;
2 # ABSTRACT: List placement groups
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 placement-group list';
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 1 ▶sub execute {
Subroutine execute: called CC=7 SCAR=22.8
Pod undocumented
12 1 my ($self, $args, $chain) = @_;
13  
14 1 my $main = $chain->[0];
15 1 my $cloud = $main->cloud;
16  
17 1 my $pgs = $cloud->placement_groups->list_all;
18  
19 1 ▶ if ($main->output eq 'json') {
Branch: 1 branch
BranchTrueFalseTotal
if ($main->output eq "json") 0 1 1
20 0 print encode_json([ map { $_->data } @$pgs ]), "\n";
21 0 return;
22 }
23  
24 1 ▶ if (!@$pgs) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@$pgs) 0 1 1
25 0 print "No placement groups found.\n";
26 0 return;
27 }
28  
29 1 printf "%-8s %-30s %-10s %-10s\n", 'ID', 'NAME', 'TYPE', 'SERVERS';
30 1 printf "%-8s %-30s %-10s %-10s\n", '-' x 8, '-' x 30, '-' x 10, '-' x 10;
31  
32 1 for my $pg (@$pgs) {
33 printf "%-8s %-30s %-10s %-10d\n",
34 $pg->id, $pg->name // '-', $pg->type // '-',
35 1 ▶ scalar(@{$pg->servers // []});
Condition50%3/6
$pg->name // "-"
l!l
10
$pg->type // "-"
l!l
10
$pg->servers // []
l!l
10
MC/DC0%0/1
$pg->name // "-"
$pg->name
MC/DC0%0/1
$pg->type // "-"
$pg->type
MC/DC0%0/1
$pg->servers // []
$pg->servers
Truth table50%1/2
A
A= $pg->name
Aresult
11
00
Truth table50%1/2
A
A= $pg->type
Aresult
11
00
Truth table50%1/2
A
A= $pg->servers
Aresult
11
00
36 }
37 }
38  
39 1 1;
40  
41 __END__
« lib/WWW/Hetzner/CLI/Cmd/Network/Cmd/List.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Snapshot/Cmd/Update.pm »