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

filter: Statementstmt 82.7% 24 / 29 Branchbran 50.0% 2 / 4 Conditioncond 60.0% 6 / 10 MC/DCmcdc 20.0% 1 / 5 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 70.3% 38 / 54 CC 9 SCAR 22.6
CC
9
Cov
74%
execute
13.4
BEGIN
1.0
BEGIN
1.0
CRAP 9.6
« lib/WWW/Hetzner/Cloud/API/Servers.pm ↑ Summary lib/WWW/Hetzner/Robot/CLI/Cmd/Server.pm »
1 package WWW::Hetzner::CLI::Cmd::PrimaryIp::Cmd::List;
2 # ABSTRACT: List primary IPs
3  
4 2 our $VERSION = '0.102';
5  
6 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use MooX::Cmd;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use MooX::Options protect_argv => 0, usage_string => 'USAGE: hcloud.pl primary-ip list';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use JSON::MaybeXS qw(encode_json);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 3 ▶sub execute {
Subroutine execute: called CC=9 SCAR=26.0
Pod undocumented
12 3 my ($self, $args, $chain) = @_;
13  
14 3 my $main = $chain->[0];
15 3 my $cloud = $main->cloud;
16  
17 3 my $pips = $cloud->primary_ips->list_all;
18  
19 3 ▶ if ($main->output eq 'json') {
Branch: 1 branch
BranchTrueFalseTotal
if ($main->output eq "json") 0 3 3
20 0 print encode_json([ map { $_->data } @$pips ]), "\n";
21 0 return;
22 }
23  
24 3 ▶ if (!@$pips) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@$pips) 0 3 3
25 0 print "No primary IPs found.\n";
26 0 return;
27 }
28  
29 3 printf "%-8s %-20s %-6s %-18s %-12s %-10s\n", 'ID', 'NAME', 'TYPE', 'IP', 'LOCATION', 'ASSIGNEE';
30 3 printf "%-8s %-20s %-6s %-18s %-12s %-10s\n", '-' x 8, '-' x 20, '-' x 6, '-' x 18, '-' x 12, '-' x 10;
31  
32 3 for my $pip (@$pips) {
33 3 ▶ printf "%-8s %-20s %-6s %-18s %-12s %-10s\n",
Condition60%6/10
$pip->name // "-"
l!l
30
$pip->type // "-"
l!l
30
$pip->ip // "-"
l!l
30
$pip->location // "-"
l!l
12
$pip->assignee_id // "-"
l!l
30
MC/DC0%0/1
$pip->name // "-"
$pip->name
MC/DC0%0/1
$pip->type // "-"
$pip->type
MC/DC0%0/1
$pip->ip // "-"
$pip->ip
MC/DC100%1/1
$pip->location // "-"
$pip->location
MC/DC0%0/1
$pip->assignee_id // "-"
$pip->assignee_id
Truth table50%1/2
A
A= $pip->name
Aresult
11
00
Truth table50%1/2
A
A= $pip->type
Aresult
11
00
Truth table50%1/2
A
A= $pip->ip
Aresult
11
00
Truth table100%2/2
A
A= $pip->location
Aresult
11
00
Truth table50%1/2
A
A= $pip->assignee_id
Aresult
11
00
34 $pip->id,
35 $pip->name // '-',
36 $pip->type // '-',
37 $pip->ip // '-',
38 $pip->location // '-',
39 $pip->assignee_id // '-';
40 }
41 }
42  
43 2 1;
44  
45 __END__
« lib/WWW/Hetzner/Cloud/API/Servers.pm ↑ Summary lib/WWW/Hetzner/Robot/CLI/Cmd/Server.pm »