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

filter: Statementstmt 82.7% 24 / 29 Branchbran 50.0% 2 / 4 Conditioncond 75.0% 3 / 4 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 77.7% 35 / 45 CC 6 SCAR 15.9
CC
6
Cov
78%
execute
7.5
BEGIN
1.0
BEGIN
1.0
CRAP 4.9
« lib/WWW/Hetzner/Cloud/API/Firewalls.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/PlacementGroup/Cmd/Describe.pm »
1 package WWW::Hetzner::CLI::Cmd::Volume::Cmd::List;
2 # ABSTRACT: List volumes
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 volume 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=6 SCAR=20.2
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 $volumes = $cloud->volumes->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 } @$volumes]), "\n";
21 0 return;
22 }
23  
24 1 ▶ if (!@$volumes) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@$volumes) 0 1 1
25 0 print "No volumes found.\n";
26 0 return;
27 }
28  
29 1 printf "%-10s %-25s %-8s %-10s %-10s %s\n",
30 'ID', 'NAME', 'SIZE', 'SERVER', 'LOCATION', 'STATUS';
31 1 print "-" x 80, "\n";
32  
33 1 for my $v (@$volumes) {
34 2 ▶ printf "%-10s %-25s %-8s %-10s %-10s %s\n",
Condition75%3/4
$v->server // "-"
l!l
11
$v->location // "-"
l!l
20
MC/DC100%1/1
$v->server // "-"
$v->server
MC/DC0%0/1
$v->location // "-"
$v->location
Truth table100%2/2
A
A= $v->server
Aresult
11
00
Truth table50%1/2
A
A= $v->location
Aresult
11
00
35 $v->id,
36 $v->name,
37 $v->size . ' GB',
38 $v->server // '-',
39 $v->location // '-',
40 $v->status;
41 }
42 }
43  
44 1 1;
45  
46 __END__
« lib/WWW/Hetzner/Cloud/API/Firewalls.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/PlacementGroup/Cmd/Describe.pm »