| 1 | package WWW::Hetzner::CLI::Cmd::Datacenter; | ||||||||||||
| 2 | # ABSTRACT: Datacenter 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 datacenter [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 | |||||||||||||
| 12 | 2 | ▶ | sub execute { | ||||||||||
|
Subroutine
execute: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||
| 13 | 2 | my ($self, $args, $chain) = @_; | |||||||||||
| 14 | |||||||||||||
| 15 | 2 | my $main = $chain->[0]; | |||||||||||
| 16 | 2 | my $cloud = $main->cloud; | |||||||||||
| 17 | 2 | my $datacenters = $cloud->datacenters->list_all; | |||||||||||
| 18 | |||||||||||||
| 19 | 2 | ▶ | if ($main->output eq 'json') { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 20 | 1 | print encode_json([ map { $_->data } @$datacenters ]), "\n"; | |||||||||||
| 21 | 1 | return; | |||||||||||
| 22 | } | ||||||||||||
| 23 | |||||||||||||
| 24 | 1 | printf "%-10s %-15s %-30s %s\n", 'ID', 'NAME', 'DESCRIPTION', 'LOCATION'; | |||||||||||
| 25 | 1 | print "-" x 80, "\n"; | |||||||||||
| 26 | |||||||||||||
| 27 | 1 | for my $d (@$datacenters) { | |||||||||||
| 28 | 3 | ▶ | printf "%-10s %-15s %-30s %s\n", | ||||||||||
|
Condition50%1/2
$d->location // "-"
MC/DC0%0/1
$d->location // "-"
$d->location
Truth table50%1/2
A
A= $d->location
| |||||||||||||
| 29 | $d->id, | ||||||||||||
| 30 | $d->name, | ||||||||||||
| 31 | $d->description, | ||||||||||||
| 32 | $d->location // '-'; | ||||||||||||
| 33 | } | ||||||||||||
| 34 | } | ||||||||||||
| 35 | |||||||||||||
| 36 | |||||||||||||
| 37 | 2 | 1; | |||||||||||
| 38 | |||||||||||||
| 39 | __END__ | ||||||||||||