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

filter: Statementstmt 94.2% 33 / 35 Branchbran 50.0% 3 / 6 Conditioncond 42.8% 3 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 75.8% 44 / 58 CC 8 SCAR 18.7
CC
8
Cov
81%
execute
9.2
BEGIN
1.0
BEGIN
1.0
CRAP 6.5
« lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/RemoveLabel.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/Firewall/Cmd/List.pm »
1 package WWW::Hetzner::CLI::Cmd::Server::Cmd::Describe;
2 # ABSTRACT: Show server details
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 server describe <id> [options]';
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=8 SCAR=22.2
Pod undocumented
12 1 my ($self, $args, $chain) = @_;
13  
14 1 ▶ my $id = $args->[0] or die "Usage: hcloud server describe <id>\n";
Branch: 1 branch
BranchTrueFalseTotal
my $id = $args->[0] or die "Usage: hcloud server describe <id>\n" 1 0 1
15  
16 1 my $main = $chain->[0];
17 1 my $cloud = $main->cloud;
18  
19 1 my $server = $cloud->servers->get($id);
20  
21 1 ▶ if ($main->output eq 'json') {
Branch: 1 branch
BranchTrueFalseTotal
if ($main->output eq "json") 0 1 1
22 0 print encode_json($server->data), "\n";
23 0 return;
24 }
25  
26 1 printf "ID: %s\n", $server->id;
27 1 printf "Name: %s\n", $server->name;
28 1 printf "Status: %s\n", $server->status;
29 1 printf "Type: %s\n", $server->server_type;
30 1 printf "Datacenter: %s\n", $server->datacenter;
31 1 ▶ printf "IPv4: %s\n", $server->ipv4 // '-';
Condition50%1/2
$server->ipv4 // "-"
l!l
10
MC/DC0%0/1
$server->ipv4 // "-"
$server->ipv4
Truth table50%1/2
A
A= $server->ipv4
Aresult
11
00
32 1 ▶ printf "IPv6: %s\n", $server->ipv6 // '-';
Condition50%1/2
$server->ipv6 // "-"
l!l
10
MC/DC0%0/1
$server->ipv6 // "-"
$server->ipv6
Truth table50%1/2
A
A= $server->ipv6
Aresult
11
00
33 1 printf "Created: %s\n", $server->created;
34  
35 1 my $labels = $server->labels;
36 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
37 1 print "Labels:\n";
38 1 for my $k (sort keys %$labels) {
39 2 printf " %s: %s\n", $k, $labels->{$k};
40 }
41 }
42 }
43  
44 1 1;
45  
46 __END__
« lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/RemoveLabel.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/Firewall/Cmd/List.pm »