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

filter: Statementstmt 93.1% 27 / 29 Branchbran 75.0% 3 / 4 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 85.7% 36 / 42 CC 5 SCAR 12.0
CC
5
Cov
89%
execute
5.2
BEGIN
1.0
BEGIN
1.0
CRAP 3.3
« lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Subaccount/Cmd/Create.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/Record/Cmd/Create.pm »
1 package WWW::Hetzner::CLI::Cmd::Sshkey;
2 # ABSTRACT: SSH key commands
3  
4 2 our $VERSION = '0.102';
5  
6 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use MooX::Cmd;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use MooX::Options usage_string => 'USAGE: hcloud.pl sshkey <command> [options]';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use JSON::MaybeXS qw(encode_json);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11  
12 2 ▶sub execute {
Subroutine execute: called CC=5 SCAR=16.4
Pod undocumented
13 2 my ($self, $args, $chain) = @_;
14  
15 # Default to list
16 2 my $main = $chain->[0];
17 2 my $cloud = $main->cloud;
18 2 my $keys = $cloud->ssh_keys->list_all;
19  
20 2 ▶ if ($main->output eq 'json') {
Branch: 1 branch
BranchTrueFalseTotal
if ($main->output eq "json") 1 1 2
21 1 print encode_json([ map { $_->data } @$keys ]), "\n";
22 1 return;
23 }
24  
25 1 ▶ if (!@$keys) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@$keys) 0 1 1
26 0 print "No SSH keys found.\n";
27 0 return;
28 }
29  
30 1 printf "%-10s %-30s %s\n", 'ID', 'NAME', 'FINGERPRINT';
31 1 print "-" x 80, "\n";
32  
33 1 for my $k (@$keys) {
34 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
35 $k->id,
36 $k->name,
37 $k->fingerprint // '-';
38 }
39 }
40  
41 2 1;
42  
43 __END__
« lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Subaccount/Cmd/Create.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/Record/Cmd/Create.pm »