lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Folders.pm

filter: Statementstmt 87.1% 27 / 31 Branchbran 50.0% 4 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 80.0% 36 / 45 CC 6 SCAR 15.7
CC
6
Cov
79%
execute
7.3
BEGIN
1.0
BEGIN
1.0
CRAP 4.8
« lib/WWW/Hetzner/CLI/Cmd/PlacementGroup/Cmd/Describe.pm ↑ Summary lib/WWW/Hetzner/Robot/API/Keys.pm »
1 package WWW::Hetzner::CLI::Cmd::StorageBox::Cmd::Folders;
2 # ABSTRACT: List Storage Box folders
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 protect_argv => 0, usage_string => 'USAGE: hcloud.pl storage-box folders [--path <path>] <storage-box>';
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 option path => (
13 is => 'ro',
14 format => 's',
15 doc => 'Folder path (default /)',
16 );
17  
18 1 ▶sub execute {
Subroutine execute: called CC=6 SCAR=19.9
Pod undocumented
19 1 my ($self, $args, $chain) = @_;
20 1 ▶ my $id = $args->[0] or die "Usage: hcloud.pl storage-box folders <storage-box>\n";
Branch: 1 branch
BranchTrueFalseTotal
my $id = $args->[0] or die "Usage: hcloud.pl storage-box folders <storage-box>\n" 1 0 1
21 1 my $main = $chain->[0];
22  
23 1 my %params;
24 1 ▶ $params{path} = $self->path if defined $self->path;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->path 0 1 1
25  
26 1 my $folders = $main->storage->storage_boxes->folders($id, %params);
27  
28 1 ▶ if ($main->output eq 'json') {
Branch: 1 branch
BranchTrueFalseTotal
if ($main->output eq "json") 0 1 1
29 0 print encode_json($folders), "\n";
30 0 return;
31 }
32  
33 1 ▶ if (!@$folders) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@$folders) 0 1 1
34 0 print "No folders found.\n";
35 0 return;
36 }
37  
38 1 printf "%s\n", 'PATH';
39 1 print '-' x 60, "\n";
40 1 for my $folder (@$folders) {
41 2 printf "%s\n", $folder;
42 }
43 }
44  
45 1 1;
46  
47 __END__
« lib/WWW/Hetzner/CLI/Cmd/PlacementGroup/Cmd/Describe.pm ↑ Summary lib/WWW/Hetzner/Robot/API/Keys.pm »