lib/WWW/Hetzner/CLI/Cmd/Zone/Cmd/List.pm

filter: Statementstmt 85.7% 30 / 35 Branchbran 50.0% 3 / 6 Conditioncond 50.0% 3 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 73.2% 41 / 56 CC 8 SCAR 20.0
CC
8
Cov
77%
execute
10.6
BEGIN
1.0
BEGIN
1.0
CRAP 7.4
« lib/WWW/Hetzner/Role/Pagination.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/Server/Cmd/List.pm »
1 package WWW::Hetzner::CLI::Cmd::Zone::Cmd::List;
2 # ABSTRACT: List DNS zones
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 usage_string => 'USAGE: hcloud.pl zone list [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 option selector => (
12 is => 'ro',
13 format => 's',
14 short => 'l',
15 doc => 'Label selector (e.g., env=prod)',
16 );
17  
18 1 ▶sub execute {
Subroutine execute: called CC=8 SCAR=23.6
Pod undocumented
19 1 my ($self, $args, $chain) = @_;
20  
21 1 my $main = $chain->[0];
22 1 my $cloud = $main->cloud;
23  
24 1 my %params;
25 1 ▶ $params{label_selector} = $self->selector if $self->selector;
Branch: 1 branch
BranchTrueFalseTotal
if $self->selector 0 1 1
26  
27 1 my $zones = $cloud->zones->list_all(%params);
28  
29 1 ▶ if ($main->output eq 'json') {
Branch: 1 branch
BranchTrueFalseTotal
if ($main->output eq "json") 0 1 1
30 0 print encode_json([map { $_->data } @$zones]), "\n";
31 0 return;
32 }
33  
34 1 ▶ if (!@$zones) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@$zones) 0 1 1
35 0 print "No zones found.\n";
36 0 return;
37 }
38  
39 1 printf "%-15s %-30s %-10s %-8s %s\n",
40 'ID', 'NAME', 'STATUS', 'TTL', 'LABELS';
41 1 print "-" x 80, "\n";
42  
43 1 for my $z (@$zones) {
44 1 my $labels = $z->labels;
45 1 my $label_str = join(', ', map { "$_=$labels->{$_}" } keys %$labels);
46 1 ▶ printf "%-15s %-30s %-10s %-8s %s\n",
Condition50%3/6
$z->status // "-"
l!l
10
$z->ttl // "-"
l!l
10
$label_str || '-'
l!l
10
MC/DC0%0/1
$z->status // "-"
$z->status
MC/DC0%0/1
$z->ttl // "-"
$z->ttl
MC/DC0%0/1
$label_str || '-'
$label_str
Truth table50%1/2
A
A= $z->status
Aresult
11
00
Truth table50%1/2
A
A= $z->ttl
Aresult
11
00
Truth table50%1/2
A
A= $label_str
Aresult
11
00
47 $z->id,
48 $z->name,
49 $z->status // '-',
50 $z->ttl // '-',
51 $label_str || '-';
52 }
53 }
54  
55 1 1;
56  
57 __END__
« lib/WWW/Hetzner/Role/Pagination.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/Server/Cmd/List.pm »