lib/WWW/Hetzner/CLI/Cmd/PrimaryIp/Cmd/Describe.pm untested

filter: Statementstmt 0.0% 0 / 42 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 18 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 76 CC 6 SCAR 32.6
CC
6
Cov
0%
execute
42.0
BEGIN
2.0
BEGIN
2.0
CRAP 26.0
1 package WWW::Hetzner::CLI::Cmd::PrimaryIp::Cmd::Describe;
2 # ABSTRACT: Describe a primary IP
3  
4 our $VERSION = '0.100';
5  
6 use Moo;
7 use MooX::Cmd;
8 use MooX::Options protect_argv => 0, usage_string => 'USAGE: hcloud.pl primary-ip describe <id>';
9 use JSON::MaybeXS qw(encode_json);
10  
11 sub execute {
12 my ($self, $args, $chain) = @_;
13 my $id = $args->[0] or die "Usage: hcloud.pl primary-ip describe <id>\n";
14  
15 my $main = $chain->[0];
16 my $cloud = $main->cloud;
17  
18 my $pip = $cloud->primary_ips->get($id);
19  
20 if ($main->output eq 'json') {
21 print encode_json($pip->data), "\n";
22 return;
23 }
24  
25 printf "ID: %s\n", $pip->id;
26 printf "Name: %s\n", $pip->name // '-';
27 printf "IP: %s\n", $pip->ip;
28 printf "Type: %s\n", $pip->type;
29 printf "Datacenter: %s\n", $pip->datacenter_name // '-';
30 printf "Assignee ID: %s\n", $pip->assignee_id // 'not assigned';
31 printf "Assignee Type:%s\n", $pip->assignee_type // '-';
32 printf "Auto Delete: %s\n", $pip->auto_delete ? 'yes' : 'no';
33 printf "Blocked: %s\n", $pip->blocked ? 'yes' : 'no';
34 printf "Created: %s\n", $pip->created // '-';
35  
36 my $dns_ptr = $pip->dns_ptr;
37 if ($dns_ptr && @$dns_ptr) {
38 print "DNS PTR:\n";
39 for my $ptr (@$dns_ptr) {
40 printf " %s -> %s\n", $ptr->{ip}, $ptr->{dns_ptr};
41 }
42 }
43  
44 my $labels = $pip->labels;
45 if ($labels && %$labels) {
46 print "Labels:\n";
47 for my $k (sort keys %$labels) {
48 printf " %s: %s\n", $k, $labels->{$k};
49 }
50 }
51 }
52  
53 1;
54  
55 __END__