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

filter: Statementstmt 82.7% 24 / 29 Branchbran 50.0% 2 / 4 Conditioncond 50.0% 5 / 10 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 66.6% 36 / 54 CC 9 SCAR 23.5
CC
9
Cov
72%
execute
14.7
BEGIN
1.0
BEGIN
1.0
CRAP 10.5
« lib/WWW/Hetzner/CLI/Cmd/Volume/Cmd/Describe.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/LoadBalancerType.pm »
1 package WWW::Hetzner::CLI::Cmd::FloatingIp::Cmd::List;
2 # ABSTRACT: List floating IPs
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 floating-ip 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=9 SCAR=26.9
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 $fips = $cloud->floating_ips->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 } @$fips ]), "\n";
21 0 return;
22 }
23  
24 1 ▶ if (!@$fips) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@$fips) 0 1 1
25 0 print "No floating IPs found.\n";
26 0 return;
27 }
28  
29 1 printf "%-8s %-20s %-6s %-18s %-10s %-10s\n", 'ID', 'NAME', 'TYPE', 'IP', 'LOCATION', 'SERVER';
30 1 printf "%-8s %-20s %-6s %-18s %-10s %-10s\n", '-' x 8, '-' x 20, '-' x 6, '-' x 18, '-' x 10, '-' x 10;
31  
32 1 for my $fip (@$fips) {
33 1 ▶ printf "%-8s %-20s %-6s %-18s %-10s %-10s\n",
Condition50%5/10
$fip->name // "-"
l!l
10
$fip->type // "-"
l!l
10
$fip->ip // "-"
l!l
10
$fip->location // "-"
l!l
10
$fip->server // "-"
l!l
10
MC/DC0%0/1
$fip->name // "-"
$fip->name
MC/DC0%0/1
$fip->type // "-"
$fip->type
MC/DC0%0/1
$fip->ip // "-"
$fip->ip
MC/DC0%0/1
$fip->location // "-"
$fip->location
MC/DC0%0/1
$fip->server // "-"
$fip->server
Truth table50%1/2
A
A= $fip->name
Aresult
11
00
Truth table50%1/2
A
A= $fip->type
Aresult
11
00
Truth table50%1/2
A
A= $fip->ip
Aresult
11
00
Truth table50%1/2
A
A= $fip->location
Aresult
11
00
Truth table50%1/2
A
A= $fip->server
Aresult
11
00
34 $fip->id,
35 $fip->name // '-',
36 $fip->type // '-',
37 $fip->ip // '-',
38 $fip->location // '-',
39 $fip->server // '-';
40 }
41 }
42  
43 1 1;
44  
45 __END__
« lib/WWW/Hetzner/CLI/Cmd/Volume/Cmd/Describe.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/LoadBalancerType.pm »