lib/WWW/Hetzner/CLI/Cmd/Servertype.pm untested

filter: Statementstmt 0.0% 0 / 25 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 35 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::Servertype;
2 # ABSTRACT: Server type commands
3  
4 our $VERSION = '0.100';
5  
6 use Moo;
7 use MooX::Cmd;
8 use MooX::Options usage_string => 'USAGE: hcloud.pl servertype [options]';
9 use JSON::MaybeXS qw(encode_json);
10  
11 sub execute {
12 my ($self, $args, $chain) = @_;
13  
14 my $main = $chain->[0];
15 my $cloud = $main->cloud;
16 my $types = $cloud->server_types->list;
17  
18 if ($main->output eq 'json') {
19 print encode_json($types), "\n";
20 return;
21 }
22  
23 printf "%-10s %-12s %-8s %-10s %-10s %s\n",
24 'ID', 'NAME', 'CORES', 'MEMORY', 'DISK', 'DEPRECATED';
25 print "-" x 70, "\n";
26  
27 for my $t (@$types) {
28 printf "%-10s %-12s %-8s %-10s %-10s %s\n",
29 $t->{id},
30 $t->{name},
31 $t->{cores},
32 $t->{memory} . ' GB',
33 $t->{disk} . ' GB',
34 $t->{deprecated} ? 'yes' : '-';
35 }
36 }
37  
38 1;
39  
40 __END__