lib/WWW/Hetzner/CLI/Cmd/Iso.pm

filter: Statementstmt 85.2% 29 / 34 Branchbran 60.0% 6 / 10 Conditioncond 62.5% 5 / 8 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 74.1% 46 / 62 CC 11 SCAR 24.5
CC
11
Cov
77%
execute
15.5
BEGIN
1.0
BEGIN
1.0
CRAP 11.6
« lib/WWW/Hetzner/Robot/CLI/Cmd/Boot/Cmd/Linux.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/AddLabel.pm »
1 package WWW::Hetzner::CLI::Cmd::Iso;
2 # ABSTRACT: ISO 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 usage_string => 'USAGE: hcloud.pl iso [--architecture x86|arm] [--name NAME] [options]';
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 architecture => (
13 is => 'ro',
14 format => 's',
15 doc => 'Filter by architecture (x86, arm)',
16 );
17  
18  
19 1 option name => (
20 is => 'ro',
21 format => 's',
22 doc => 'Filter by exact ISO name',
23 );
24  
25  
26 1 ▶sub execute {
Subroutine execute: called CC=11 SCAR=27.4
Pod undocumented
27 1 my ($self, $args, $chain) = @_;
28  
29 1 my $main = $chain->[0];
30 1 my $cloud = $main->cloud;
31  
32 1 my %params;
33 1 ▶ $params{architecture} = $self->architecture if $self->architecture;
Branch: 1 branch
BranchTrueFalseTotal
if $self->architecture 1 0 1
34 1 ▶ $params{name} = $self->name if $self->name;
Branch: 1 branch
BranchTrueFalseTotal
if $self->name 1 0 1
35  
36 1 my $isos = $cloud->isos->list_all(%params);
37  
38 1 ▶ if ($main->output eq 'json') {
Branch: 1 branch
BranchTrueFalseTotal
if ($main->output eq "json") 0 1 1
39 0 print encode_json([ map { $_->data } @$isos ]), "\n";
40 0 return;
41 }
42  
43 1 ▶ if (!@$isos) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@$isos) 0 1 1
44 0 print "No ISOs found.\n";
45 0 return;
46 }
47  
48 1 printf "%-8s %-40s %-8s %-6s %s\n", 'ID', 'NAME', 'TYPE', 'ARCH', 'DEPRECATED';
49 1 printf "%-8s %-40s %-8s %-6s %s\n", '-' x 8, '-' x 40, '-' x 8, '-' x 6, '-' x 10;
50  
51 1 for my $iso (@$isos) {
52 printf "%-8s %-40s %-8s %-6s %s\n",
53 $iso->id,
54 $iso->name // '-',
55 $iso->type // '-',
56 $iso->architecture // '-',
57 ($iso->deprecation ? $iso->deprecation->{unavailable_after}
58 3 ▶ : $iso->deprecated) // '-';
Branch: 1 branch
BranchTrueFalseTotal
$iso->deprecation ? : 1 2 3
Condition62%5/8
$iso->name // "-"
l!l
30
$iso->type // "-"
l!l
30
$iso->architecture // "-"
l!l
30
($iso->deprecation ? $iso->deprecation->{"unavailable_after"} : $iso->deprecated) // "-"
l!l
12
MC/DC0%0/1
$iso->name // "-"
$iso->name
MC/DC0%0/1
$iso->type // "-"
$iso->type
MC/DC0%0/1
$iso->architecture // "-"
$iso->architecture
MC/DC100%1/1
($iso->deprecation ? $iso->deprecation->{"unavailable_after"} : $iso->deprecated) // "-"
($iso->deprecation ? $iso->deprecation->{"unavailable_after"} : $iso->deprecated)
Truth table50%1/2
A
A= $iso->name
Aresult
11
00
Truth table50%1/2
A
A= $iso->type
Aresult
11
00
Truth table50%1/2
A
A= $iso->architecture
Aresult
11
00
Truth table100%2/2
A
A= ($iso->deprecation ? $iso->deprecation->{"unavailable_after"} : $iso->deprecated)
Aresult
11
00
59 }
60 }
61  
62 1 1;
63  
64 __END__
« lib/WWW/Hetzner/Robot/CLI/Cmd/Boot/Cmd/Linux.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/AddLabel.pm »