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

filter: Statementstmt 91.1% 31 / 34 Branchbran 50.0% 4 / 8 Conditioncond 50.0% 2 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 77.7% 42 / 54 CC 8 SCAR 18.9
CC
8
Cov
80%
execute
9.4
BEGIN
1.0
BEGIN
1.0
CRAP 6.6
« lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Snapshot/Cmd/Update.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/Server/Cmd/Describe.pm »
1 package WWW::Hetzner::CLI::Cmd::StorageBox::Cmd::RemoveLabel;
2 # ABSTRACT: Remove a label from 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 remove-label <storage-box> <key>';
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=8 SCAR=22.4
Pod undocumented
13 1 my ($self, $args, $chain) = @_;
14 1 ▶ my $id = $args->[0] or die "Usage: hcloud.pl storage-box remove-label <storage-box> <key>\n";
Branch: 1 branch
BranchTrueFalseTotal
my $id = $args->[0] or die "Usage: hcloud.pl storage-box remove-label <storage-box> <key>\n" 1 0 1
15 1 ▶ my $key = $args->[1] or die "Usage: hcloud.pl storage-box remove-label <storage-box> <key>\n";
Branch: 1 branch
BranchTrueFalseTotal
my $key = $args->[1] or die "Usage: hcloud.pl storage-box remove-label <storage-box> <key>\n" 1 0 1
16  
17 1 my $main = $chain->[0];
18 1 my $box = $main->storage->storage_boxes->get($id);
19 1 ▶ my %labels = %{ $box->labels // {} };
Condition50%1/2
$box->labels // {}
l!l
10
MC/DC0%0/1
$box->labels // {}
$box->labels
Truth table50%1/2
A
A= $box->labels
Aresult
11
00
20 1 delete $labels{$key};
21 1 my $updated = $main->storage->storage_boxes->update($id, labels => \%labels);
22  
23 1 ▶ if ($main->output eq 'json') {
Branch: 1 branch
BranchTrueFalseTotal
if ($main->output eq "json") 0 1 1
24 0 print encode_json($updated->data), "\n";
25 0 return;
26 }
27  
28 1 print "Storage Box labels updated:\n";
29 1 printf " ID: %s\n", $updated->id;
30 1 printf " Name: %s\n", $updated->name;
31 1 ▶ my $new_labels = $updated->labels // {};
Condition50%1/2
$updated->labels // {}
l!l
10
MC/DC0%0/1
$updated->labels // {}
$updated->labels
Truth table50%1/2
A
A= $updated->labels
Aresult
11
00
32 1 ▶ if (%$new_labels) {
Branch: 1 branch
BranchTrueFalseTotal
if (%$new_labels) { } 1 0 1
33 1 print " Labels:\n";
34 1 printf " %s: %s\n", $_, $new_labels->{$_} for sort keys %$new_labels;
35 } else {
36 0 print " Labels: (none)\n";
37 }
38 }
39  
40 1 1;
41  
42 __END__
« lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Snapshot/Cmd/Update.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/Server/Cmd/Describe.pm »