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

filter: Statementstmt 94.5% 35 / 37 Branchbran 50.0% 7 / 14 Conditioncond 50.0% 4 / 8 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 74.2% 52 / 70 CC 12 SCAR 25.1
CC
12
Cov
78%
execute
16.9
BEGIN
1.0
BEGIN
1.0
CRAP 12.3
« lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Subaccount/Cmd/Describe.pm ↑ Summary lib/WWW/Hetzner/Robot/CLI/Cmd/Boot/Cmd/Linux.pm »
1 package WWW::Hetzner::CLI::Cmd::StorageBox::Cmd::Subaccount::Cmd::Update;
2 # ABSTRACT: Update a Storage Box subaccount
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 update [--name <name>] [--description <description>] <storage-box> <subaccount>';
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 option name => (
14 is => 'ro',
15 format => 's',
16 doc => 'New subaccount name',
17 );
18  
19 1 option description => (
20 is => 'ro',
21 format => 's',
22 doc => 'New subaccount description',
23 );
24  
25 1 ▶sub execute {
Subroutine execute: called CC=12 SCAR=28.3
Pod undocumented
26 1 my ($self, $args, $chain) = @_;
27 1 ▶ my $id = $args->[0] or die "Usage: hcloud.pl storage-box subaccount update <storage-box> <subaccount>\n";
Branch: 1 branch
BranchTrueFalseTotal
my $id = $args->[0] or die "Usage: hcloud.pl storage-box subaccount update <storage-box> <subaccount>\n" 1 0 1
28 1 ▶ my $sub = $args->[1] or die "Usage: hcloud.pl storage-box subaccount update <storage-box> <subaccount>\n";
Branch: 1 branch
BranchTrueFalseTotal
my $sub = $args->[1] or die "Usage: hcloud.pl storage-box subaccount update <storage-box> <subaccount>\n" 1 0 1
29 1 my $main = $chain->[0];
30  
31 1 my %body;
32 1 ▶ $body{name} = $self->name if defined $self->name;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->name 1 0 1
33 1 ▶ $body{description} = $self->description if defined $self->description;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->description 1 0 1
34  
35 1 my $subaccounts = WWW::Hetzner::Storage::API::Subaccounts->new(
36 client => $main->storage,
37 storage_box_id => $id,
38 );
39 1 my $subaccount = $subaccounts->update($sub, %body);
40  
41 1 ▶ if ($main->output eq 'json') {
Branch: 1 branch
BranchTrueFalseTotal
if ($main->output eq "json") 0 1 1
42 0 print encode_json($subaccount->data), "\n";
43 0 return;
44 }
45  
46 1 print "Subaccount updated:\n";
47 1 printf " ID: %s\n", $subaccount->id;
48 1 ▶ printf " Name: %s\n", ($subaccount->name // '') ne '' ? $subaccount->name : '-';
Branch: 1 branch
BranchTrueFalseTotal
($subaccount->name // '') ne '' ? : 1 0 1
Condition50%1/2
$subaccount->name // ""
l!l
10
MC/DC0%0/1
$subaccount->name // ""
$subaccount->name
Truth table50%1/2
A
A= $subaccount->name
Aresult
11
00
49 1 ▶ printf " Username: %s\n", $subaccount->username // '-';
Condition50%1/2
$subaccount->username // "-"
l!l
10
MC/DC0%0/1
$subaccount->username // "-"
$subaccount->username
Truth table50%1/2
A
A= $subaccount->username
Aresult
11
00
50 1 ▶ printf " Home Directory: %s\n", $subaccount->home_directory // '-';
Condition50%1/2
$subaccount->home_directory // "-"
l!l
10
MC/DC0%0/1
$subaccount->home_directory // "-"
$subaccount->home_directory
Truth table50%1/2
A
A= $subaccount->home_directory
Aresult
11
00
51 1 ▶ printf " Description: %s\n", ($subaccount->description // '') ne '' ? $subaccount->description : '-';
Branch: 1 branch
BranchTrueFalseTotal
($subaccount->description // '') ne '' ? : 1 0 1
Condition50%1/2
$subaccount->description // ""
l!l
10
MC/DC0%0/1
$subaccount->description // ""
$subaccount->description
Truth table50%1/2
A
A= $subaccount->description
Aresult
11
00
52 }
53  
54 1 1;
55  
56 __END__
« lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Subaccount/Cmd/Describe.pm ↑ Summary lib/WWW/Hetzner/Robot/CLI/Cmd/Boot/Cmd/Linux.pm »