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

filter: Statementstmt 0.0% 0 / 26 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 4 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 38 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::Sshkey::Cmd::Describe;
2 # ABSTRACT: Describe an SSH key
3  
4 our $VERSION = '0.100';
5  
6 use Moo;
7 use MooX::Cmd;
8 use MooX::Options protect_argv => 0, usage_string => 'USAGE: hcloud.pl sshkey describe <id>';
9 use JSON::MaybeXS qw(encode_json);
10  
11 sub execute {
12 my ($self, $args, $chain) = @_;
13 my $id = $args->[0] or die "Usage: hcloud.pl sshkey describe <id>\n";
14  
15 my $main = $chain->[0];
16 my $cloud = $main->cloud;
17  
18 my $key = $cloud->ssh_keys->get($id);
19  
20 if ($main->output eq 'json') {
21 print encode_json($key->data), "\n";
22 } else {
23 printf "ID: %s\n", $key->id;
24 printf "Name: %s\n", $key->name;
25 printf "Fingerprint: %s\n", $key->fingerprint;
26 printf "Created: %s\n", $key->created // '-';
27 printf "Public Key:\n%s\n", $key->public_key;
28 }
29 }
30  
31 1;
32  
33 __END__