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

filter: Statementstmt 0.0% 0 / 36 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 15 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 61 CC 3 SCAR 18.4
CC
3
Cov
0%
execute
12.0
BEGIN
2.0
BEGIN
2.0
CRAP 6.3
1 package WWW::Hetzner::CLI::Cmd::Volume::Cmd::Describe;
2 # ABSTRACT: Describe a volume
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 volume 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 volume describe <id>\n";
14  
15 my $main = $chain->[0];
16 my $cloud = $main->cloud;
17  
18 my $volume = $cloud->volumes->get($id);
19  
20 if ($main->output eq 'json') {
21 print encode_json($volume->data), "\n";
22 return;
23 }
24  
25 printf "ID: %s\n", $volume->id;
26 printf "Name: %s\n", $volume->name;
27 printf "Size: %s GB\n", $volume->size;
28 printf "Status: %s\n", $volume->status;
29 printf "Location: %s\n", $volume->location // '-';
30 printf "Server: %s\n", $volume->server // 'not attached';
31 printf "Linux Device: %s\n", $volume->linux_device // '-';
32 printf "Format: %s\n", $volume->format // '-';
33 printf "Created: %s\n", $volume->created // '-';
34  
35 my $labels = $volume->labels;
36 if ($labels && %$labels) {
37 print "Labels:\n";
38 for my $k (sort keys %$labels) {
39 printf " %s: %s\n", $k, $labels->{$k};
40 }
41 }
42 }
43  
44 1;
45  
46 __END__