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

filter: Statementstmt 85.2% 29 / 34 Branchbran 50.0% 5 / 10 Conditioncond 50.0% 4 / 8 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 1 totaltotal 70.3% 45 / 64 CC 11 SCAR 26.0
CC
11
Cov
73%
_list
20.2
BEGIN
1.0
BEGIN
1.0
CRAP 13.4
« lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Snapshot/Cmd/AddLabel.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Subaccount/Cmd/Describe.pm »
1 package WWW::Hetzner::CLI::Cmd::StorageBox::Cmd::Subaccount;
2 # ABSTRACT: Storage Box subaccount 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 protect_argv => 0, usage_string => 'USAGE: hcloud.pl storage-box subaccount <command> [options] <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=1 SCAR=0.0
Pod undocumented
14 1 my ($self, $args, $chain) = @_;
15 1 $self->_list($args, $chain);
16 }
17  
18 1 ▶sub _list {
Subroutine _list: called CC=11 SCAR=30.1
19 1 my ($self, $args, $chain) = @_;
20 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
21 1 my $main = $chain->[0];
22 1 my $subaccounts = WWW::Hetzner::Storage::API::Subaccounts->new(
23 client => $main->storage,
24 storage_box_id => $id,
25 )->list;
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 } @$subaccounts]), "\n";
29 0 return;
30 }
31  
32 1 ▶ if (!@$subaccounts) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@$subaccounts) 0 1 1
33 0 print "No subaccounts found.\n";
34 0 return;
35 }
36  
37 1 printf "%-10s %-25s %-25s %-40s %s\n", 'ID', 'NAME', 'USERNAME', 'HOME_DIRECTORY', 'DESCRIPTION';
38 1 print '-' x 120, "\n";
39 1 for my $sub (@$subaccounts) {
40 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
41 $sub->id,
42 ($sub->name // '') ne '' ? $sub->name : '-',
43 $sub->username // '-',
44 $sub->home_directory // '-',
45 ($sub->description // '') ne '' ? $sub->description : '-';
46 }
47 }
48  
49  
50 1 1;
51  
52 __END__
« lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Snapshot/Cmd/AddLabel.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Subaccount/Cmd/Describe.pm »