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

filter: Statementstmt 93.3% 42 / 45 Branchbran 50.0% 6 / 12 Conditioncond 35.7% 5 / 14 MC/DCmcdc 0.0% 0 / 9 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 67.4% 58 / 86 CC 15 SCAR 28.7
CC
15
Cov
75%
execute
22.1
BEGIN
1.0
BEGIN
1.0
CRAP 17.6
« lib/WWW/Hetzner/Cloud/Costs.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/Costs.pm »
1 package WWW::Hetzner::CLI::Cmd::Network::Cmd::Describe;
2 # ABSTRACT: Describe a network
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 network describe <id>';
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=15 SCAR=30.9
Pod undocumented
12 1 my ($self, $args, $chain) = @_;
13 1 ▶ my $id = $args->[0] or die "Usage: hcloud.pl network describe <id>\n";
Branch: 1 branch
BranchTrueFalseTotal
my $id = $args->[0] or die "Usage: hcloud.pl network describe <id>\n" 1 0 1
14  
15 1 my $main = $chain->[0];
16 1 my $cloud = $main->cloud;
17  
18 1 my $network = $cloud->networks->get($id);
19  
20 1 ▶ if ($main->output eq 'json') {
Branch: 1 branch
BranchTrueFalseTotal
if ($main->output eq "json") 0 1 1
21 0 print encode_json($network->data), "\n";
22 0 return;
23 }
24  
25 1 printf "ID: %s\n", $network->id;
26 1 printf "Name: %s\n", $network->name;
27 1 printf "IP Range: %s\n", $network->ip_range;
28 1 ▶ printf "Created: %s\n", $network->created // '-';
Condition50%1/2
$network->created // "-"
l!l
10
MC/DC0%0/1
$network->created // "-"
$network->created
Truth table50%1/2
A
A= $network->created
Aresult
11
00
29  
30 1 my $servers = $network->servers;
31 1 ▶ if ($servers && @$servers) {
Branch: 1 branch
BranchTrueFalseTotal
if ($servers and @$servers) { } 1 0 1
Condition33%1/3
$servers and @$servers
!ll&&!rl&&r
001
MC/DC0%0/2
$servers and @$servers
$servers @$servers
Truth table33%1/3
A and B
A= $serversB= @$servers
ABresult
0X0
100
111
32 1 printf "Servers: %s\n", join(', ', @$servers);
33 } else {
34 0 print "Servers: none\n";
35 }
36  
37 1 my $subnets = $network->subnets;
38 1 ▶ if ($subnets && @$subnets) {
Branch: 1 branch
BranchTrueFalseTotal
if ($subnets and @$subnets) 1 0 1
Condition33%1/3
$subnets and @$subnets
!ll&&!rl&&r
001
MC/DC0%0/2
$subnets and @$subnets
$subnets @$subnets
Truth table33%1/3
A and B
A= $subnetsB= @$subnets
ABresult
0X0
100
111
39 1 print "\nSubnets:\n";
40 1 for my $s (@$subnets) {
41 printf " - %s (%s, %s)\n",
42 $s->{ip_range},
43 $s->{network_zone},
44 1 $s->{type};
45 }
46 }
47  
48 1 my $routes = $network->routes;
49 1 ▶ if ($routes && @$routes) {
Branch: 1 branch
BranchTrueFalseTotal
if ($routes and @$routes) 1 0 1
Condition33%1/3
$routes and @$routes
!ll&&!rl&&r
001
MC/DC0%0/2
$routes and @$routes
$routes @$routes
Truth table33%1/3
A and B
A= $routesB= @$routes
ABresult
0X0
100
111
50 1 print "\nRoutes:\n";
51 1 for my $r (@$routes) {
52 1 printf " - %s via %s\n", $r->{destination}, $r->{gateway};
53 }
54 }
55  
56 1 my $labels = $network->labels;
57 1 ▶ if ($labels && %$labels) {
Branch: 1 branch
BranchTrueFalseTotal
if ($labels and %$labels) 1 0 1
Condition33%1/3
$labels and %$labels
!ll&&!rl&&r
001
MC/DC0%0/2
$labels and %$labels
$labels %$labels
Truth table33%1/3
A and B
A= $labelsB= %$labels
ABresult
0X0
100
111
58 1 print "\nLabels:\n";
59 1 for my $k (sort keys %$labels) {
60 1 printf " %s: %s\n", $k, $labels->{$k};
61 }
62 }
63 }
64  
65 1 1;
66  
67 __END__
« lib/WWW/Hetzner/Cloud/Costs.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/Costs.pm »