lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Subaccount/Cmd/List.pm

filter: Statementstmt 84.3% 27 / 32 Branchbran 50.0% 5 / 10 Conditioncond 50.0% 4 / 8 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 68.8% 42 / 61 CC 11 SCAR 26.6
CC
11
Cov
72%
execute
20.2
BEGIN
1.0
BEGIN
1.0
CRAP 14.2
« lib/WWW/Hetzner/Robot/CLI/Cmd/Server/Cmd/Describe.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Snapshot/Cmd/AddLabel.pm »
1 package WWW::Hetzner::CLI::Cmd::StorageBox::Cmd::Subaccount::Cmd::List;
2 # ABSTRACT: List subaccounts of a Storage Box
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 subaccount list <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 1 ▶use WWW::Hetzner::Storage::API::Subaccounts;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12  
13 1 ▶sub execute {
Subroutine execute: called CC=11 SCAR=30.1
Pod undocumented
14 1 my ($self, $args, $chain) = @_;
15 1 ▶ my $id = $args->[0] or die "Usage: hcloud.pl storage-box subaccount list <storage-box>\n";
Branch: 1 branch
BranchTrueFalseTotal
my $id = $args->[0] or die "Usage: hcloud.pl storage-box subaccount list <storage-box>\n" 1 0 1
16 1 my $main = $chain->[0];
17 1 my $subaccounts = WWW::Hetzner::Storage::API::Subaccounts->new(
18 client => $main->storage,
19 storage_box_id => $id,
20 )->list;
21  
22 1 ▶ if ($main->output eq 'json') {
Branch: 1 branch
BranchTrueFalseTotal
if ($main->output eq "json") 0 1 1
23 0 print encode_json([map { $_->data } @$subaccounts]), "\n";
24 0 return;
25 }
26  
27 1 ▶ if (!@$subaccounts) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@$subaccounts) 0 1 1
28 0 print "No subaccounts found.\n";
29 0 return;
30 }
31  
32 1 printf "%-10s %-25s %-25s %-40s %s\n", 'ID', 'NAME', 'USERNAME', 'HOME_DIRECTORY', 'DESCRIPTION';
33 1 print '-' x 120, "\n";
34 1 for my $sub (@$subaccounts) {
35 1 ▶ printf "%-10s %-25s %-25s %-40s %s\n",
Branch: 2 branches
BranchTrueFalseTotal
($sub->name // '') ne '' ? : 1 0 1
($sub->description // '') ne '' ? : 1 0 1
Condition50%4/8
$sub->name // ""
l!l
10
$sub->username // "-"
l!l
10
$sub->home_directory // "-"
l!l
10
$sub->description // ""
l!l
10
MC/DC0%0/1
$sub->name // ""
$sub->name
MC/DC0%0/1
$sub->username // "-"
$sub->username
MC/DC0%0/1
$sub->home_directory // "-"
$sub->home_directory
MC/DC0%0/1
$sub->description // ""
$sub->description
Truth table50%1/2
A
A= $sub->name
Aresult
11
00
Truth table50%1/2
A
A= $sub->username
Aresult
11
00
Truth table50%1/2
A
A= $sub->home_directory
Aresult
11
00
Truth table50%1/2
A
A= $sub->description
Aresult
11
00
36 $sub->id,
37 ($sub->name // '') ne '' ? $sub->name : '-',
38 $sub->username // '-',
39 $sub->home_directory // '-',
40 ($sub->description // '') ne '' ? $sub->description : '-';
41 }
42 }
43  
44 1 1;
45  
46 __END__
« lib/WWW/Hetzner/Robot/CLI/Cmd/Server/Cmd/Describe.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Snapshot/Cmd/AddLabel.pm »