| 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
| |||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||
| 26 | 2 | my $images = $cloud->images->list_all(%params); | |||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||
| 28 | 2 | ▶ | if ($main->output eq 'json') { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 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 // "-"
$i->os_flavor // ""
$i->os_version // ""
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
Truth table50%1/2
A
A= $i->os_flavor
Truth table50%1/2
A
A= $i->os_version
| |||||||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||||||