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

filter: Statementstmt 0.0% 0 / 25 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 33 CC 2 SCAR 12.0
CC
2
Cov
0%
execute
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 3.3
1 package WWW::Hetzner::CLI::Cmd::Location;
2 # ABSTRACT: Location commands
3  
4 our $VERSION = '0.100';
5  
6 use Moo;
7 use MooX::Cmd;
8 use MooX::Options usage_string => 'USAGE: hcloud.pl location [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 $locations = $cloud->locations->list;
17  
18 if ($main->output eq 'json') {
19 print encode_json($locations), "\n";
20 return;
21 }
22  
23 printf "%-10s %-30s %-10s %s\n", 'ID', 'NAME', 'COUNTRY', 'CITY';
24 print "-" x 70, "\n";
25  
26 for my $l (@$locations) {
27 printf "%-10s %-30s %-10s %s\n",
28 $l->{id},
29 $l->{name},
30 $l->{country},
31 $l->{city};
32 }
33 }
34  
35 1;
36  
37 __END__