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

filter: Statementstmt 83.8% 26 / 31 Branchbran 50.0% 2 / 4 Conditioncond 75.0% 3 / 4 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 79.1% 38 / 48 CC 6 SCAR 15.2
CC
6
Cov
79%
_list
7.5
BEGIN
1.0
BEGIN
1.0
CRAP 4.6
« lib/WWW/Hetzner/Robot/API/Keys.pm ↑ Summary lib/WWW/Hetzner/LWPIO.pm »
1 package WWW::Hetzner::CLI::Cmd::Volume;
2 # ABSTRACT: Volume commands
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 <command> [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  
12 1 ▶sub execute {
Subroutine execute: called CC=1 SCAR=0.0
Pod undocumented
13 1 my ($self, $args, $chain) = @_;
14  
15 # Default to list
16 1 $self->_list($chain);
17 }
18  
19 1 ▶sub _list {
Subroutine _list: called CC=6 SCAR=20.2
20 1 my ($self, $chain) = @_;
21  
22 1 my $main = $chain->[0];
23 1 my $cloud = $main->cloud;
24  
25 1 my $volumes = $cloud->volumes->list_all;
26  
27 1 ▶ if ($main->output eq 'json') {
Branch: 1 branch
BranchTrueFalseTotal
if ($main->output eq "json") 0 1 1
28 0 print encode_json([map { $_->data } @$volumes]), "\n";
29 0 return;
30 }
31  
32 1 ▶ if (!@$volumes) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@$volumes) 0 1 1
33 0 print "No volumes found.\n";
34 0 return;
35 }
36  
37 1 printf "%-10s %-25s %-8s %-10s %-10s %s\n",
38 'ID', 'NAME', 'SIZE', 'SERVER', 'LOCATION', 'STATUS';
39 1 print "-" x 80, "\n";
40  
41 1 for my $v (@$volumes) {
42 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
43 $v->id,
44 $v->name,
45 $v->size . ' GB',
46 $v->server // '-',
47 $v->location // '-',
48 $v->status;
49 }
50 }
51  
52 1 1;
53  
54 __END__
« lib/WWW/Hetzner/Robot/API/Keys.pm ↑ Summary lib/WWW/Hetzner/LWPIO.pm »