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

filter: Statementstmt 0.0% 0 / 30 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 7 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 47 CC 3 SCAR 18.4
CC
3
Cov
0%
execute
12.0
BEGIN
2.0
BEGIN
2.0
CRAP 6.3
1 package WWW::Hetzner::CLI::Cmd::PlacementGroup::Cmd::Describe;
2 # ABSTRACT: Describe a placement group
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 placement-group 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 placement-group describe <id>\n";
14  
15 my $main = $chain->[0];
16 my $cloud = $main->cloud;
17  
18 my $pg = $cloud->placement_groups->get($id);
19  
20 if ($main->output eq 'json') {
21 print encode_json($pg->data), "\n";
22 return;
23 }
24  
25 printf "ID: %s\n", $pg->id;
26 printf "Name: %s\n", $pg->name;
27 printf "Type: %s\n", $pg->type;
28 printf "Created: %s\n", $pg->created // '-';
29  
30 my $servers = $pg->servers;
31 if ($servers && @$servers) {
32 printf "Servers: %s\n", join(', ', @$servers);
33 } else {
34 print "Servers: none\n";
35 }
36 }
37  
38 1;
39  
40 __END__