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

filter: Statementstmt 84.3% 27 / 32 Branchbran 50.0% 3 / 6 Conditioncond 50.0% 4 / 8 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 69.6% 39 / 56 CC 9 SCAR 22.5
CC
9
Cov
74%
execute
13.3
BEGIN
1.0
BEGIN
1.0
CRAP 9.5
« lib/WWW/Hetzner/Robot/CLI/Cmd/Server/Cmd/List.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/Certificate/Cmd/Describe.pm »
1 package WWW::Hetzner::CLI::Cmd::Certificate::Cmd::List;
2 # ABSTRACT: List certificates
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 protect_argv => 0, usage_string => 'USAGE: hcloud.pl certificate list';
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 ▶sub execute {
Subroutine execute: called CC=9 SCAR=25.9
Pod undocumented
12 1 my ($self, $args, $chain) = @_;
13  
14 1 my $main = $chain->[0];
15 1 my $cloud = $main->cloud;
16  
17 1 my $certs = $cloud->certificates->list_all;
18  
19 1 ▶ if ($main->output eq 'json') {
Branch: 1 branch
BranchTrueFalseTotal
if ($main->output eq "json") 0 1 1
20 0 print encode_json([ map { $_->data } @$certs ]), "\n";
21 0 return;
22 }
23  
24 1 ▶ if (!@$certs) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@$certs) 0 1 1
25 0 print "No certificates found.\n";
26 0 return;
27 }
28  
29 1 printf "%-8s %-30s %-10s %-30s\n", 'ID', 'NAME', 'TYPE', 'DOMAINS';
30 1 printf "%-8s %-30s %-10s %-30s\n", '-' x 8, '-' x 30, '-' x 10, '-' x 30;
31  
32 1 for my $c (@$certs) {
33 1 ▶ my $domains = join(', ', @{$c->domain_names // []}) || '-';
Condition50%2/4
join(', ', @{$c->domain_names // [];}) || '-'
l!l
10
$c->domain_names // []
l!l
10
MC/DC0%0/1
join(', ', @{$c->domain_names // [];}) || '-'
join(', ', @{$c->domain_names // [];})
MC/DC0%0/1
$c->domain_names // []
$c->domain_names
Truth table50%1/2
A
A= join(', ', @{$c->domain_names // [];})
Aresult
11
00
Truth table50%1/2
A
A= $c->domain_names
Aresult
11
00
34 1 ▶ $domains = substr($domains, 0, 27) . '...' if length($domains) > 30;
Branch: 1 branch
BranchTrueFalseTotal
if length $domains > 30 0 1 1
35 1 ▶ printf "%-8s %-30s %-10s %-30s\n",
Condition50%2/4
$c->name // "-"
l!l
10
$c->type // "-"
l!l
10
MC/DC0%0/1
$c->name // "-"
$c->name
MC/DC0%0/1
$c->type // "-"
$c->type
Truth table50%1/2
A
A= $c->name
Aresult
11
00
Truth table50%1/2
A
A= $c->type
Aresult
11
00
36 $c->id, $c->name // '-', $c->type // '-', $domains;
37 }
38 }
39  
40 1 1;
41  
42 __END__
« lib/WWW/Hetzner/Robot/CLI/Cmd/Server/Cmd/List.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/Certificate/Cmd/Describe.pm »