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

filter: Statementstmt 82.7% 24 / 29 Branchbran 50.0% 2 / 4 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 76.1% 32 / 42 CC 5 SCAR 13.8
CC
5
Cov
77%
execute
6.4
BEGIN
1.0
BEGIN
1.0
CRAP 4.0
« lib/WWW/Hetzner/CLI/Cmd/Zone/Cmd/Create.pm ↑ Summary lib/WWW/Hetzner/Cloud/FloatingIP.pm »
1 package WWW::Hetzner::CLI::Cmd::Sshkey::Cmd::List;
2 # ABSTRACT: List SSH keys
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 sshkey 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 ▶sub execute {
Subroutine execute: called CC=5 SCAR=18.5
Pod undocumented
12 1 my ($self, $args, $chain) = @_;
13  
14 1 my $main = $chain->[0];
15 1 my $cloud = $main->cloud;
16 1 my $keys = $cloud->ssh_keys->list_all;
17  
18 1 ▶ if ($main->output eq 'json') {
Branch: 1 branch
BranchTrueFalseTotal
if ($main->output eq "json") 0 1 1
19 0 print encode_json([map { $_->data } @$keys]), "\n";
20 0 return;
21 }
22  
23 1 ▶ if (!@$keys) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@$keys) 0 1 1
24 0 print "No SSH keys found.\n";
25 0 return;
26 }
27  
28 1 printf "%-10s %-30s %s\n", 'ID', 'NAME', 'FINGERPRINT';
29 1 print "-" x 80, "\n";
30  
31 1 for my $k (@$keys) {
32 1 ▶ printf "%-10s %-30s %s\n",
Condition50%1/2
$k->fingerprint // "-"
l!l
10
MC/DC0%0/1
$k->fingerprint // "-"
$k->fingerprint
Truth table50%1/2
A
A= $k->fingerprint
Aresult
11
00
33 $k->id,
34 $k->name,
35 $k->fingerprint // '-';
36 }
37 }
38  
39 1 1;
40  
41 __END__
« lib/WWW/Hetzner/CLI/Cmd/Zone/Cmd/Create.pm ↑ Summary lib/WWW/Hetzner/Cloud/FloatingIP.pm »