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

filter: Statementstmt 100% 29 / 29 Branchbran 75.0% 3 / 4 Conditioncond 50.0% 3 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 83.3% 40 / 48 CC 7 SCAR 16.0
CC
7
Cov
90%
execute
7.2
BEGIN
1.0
BEGIN
1.0
CRAP 5.0
« lib/WWW/Hetzner/Robot/Server.pm ↑ Summary lib/WWW/Hetzner/Cloud/API/Firewalls.pm »
1 package WWW::Hetzner::CLI::Cmd::Image;
2 # ABSTRACT: Image commands
3  
4 2 our $VERSION = '0.102';
5  
6 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use MooX::Cmd;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use MooX::Options usage_string => 'USAGE: hcloud.pl image [--type system|snapshot|backup] [options]';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use JSON::MaybeXS qw(encode_json);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 option type => (
12 is => 'ro',
13 format => 's',
14 doc => 'Filter by type (system, snapshot, backup)',
15 );
16  
17 2 ▶sub execute {
Subroutine execute: called CC=7 SCAR=19.8
Pod undocumented
18 2 my ($self, $args, $chain) = @_;
19  
20 2 my $main = $chain->[0];
21 2 my $cloud = $main->cloud;
22  
23 2 my %params;
24 2 ▶ $params{type} = $self->type if $self->type;
Branch: 1 branch
BranchTrueFalseTotal
if $self->type 0 2 2
25  
26 2 my $images = $cloud->images->list_all(%params);
27  
28 2 ▶ if ($main->output eq 'json') {
Branch: 1 branch
BranchTrueFalseTotal
if ($main->output eq "json") 1 1 2
29 1 print encode_json([ map { $_->data } @$images ]), "\n";
30 1 return;
31 }
32  
33 1 printf "%-10s %-20s %-10s %-15s %s\n",
34 'ID', 'NAME', 'TYPE', 'OS', 'STATUS';
35 1 print "-" x 70, "\n";
36  
37 1 for my $i (@$images) {
38 3 ▶ printf "%-10s %-20s %-10s %-15s %s\n",
Condition50%3/6
$i->name // "-"
l!l
30
$i->os_flavor // ""
l!l
30
$i->os_version // ""
l!l
30
MC/DC0%0/1
$i->name // "-"
$i->name
MC/DC0%0/1
$i->os_flavor // ""
$i->os_flavor
MC/DC0%0/1
$i->os_version // ""
$i->os_version
Truth table50%1/2
A
A= $i->name
Aresult
11
00
Truth table50%1/2
A
A= $i->os_flavor
Aresult
11
00
Truth table50%1/2
A
A= $i->os_version
Aresult
11
00
39 $i->id,
40 $i->name // '-',
41 $i->type,
42 ($i->os_flavor // '') . ' ' . ($i->os_version // ''),
43 $i->status;
44 }
45 }
46  
47 2 1;
48  
49 __END__
« lib/WWW/Hetzner/Robot/Server.pm ↑ Summary lib/WWW/Hetzner/Cloud/API/Firewalls.pm »